added OI example

git-svn-id: trunk@4607 -
This commit is contained in:
mattias 2003-09-12 16:20:55 +00:00
parent fb8af62ec2
commit 52880372e2
8 changed files with 287 additions and 4 deletions

5
.gitattributes vendored
View File

@ -298,6 +298,11 @@ examples/messagedialogs.pp svneol=native#text/pascal
examples/notebk.pp svneol=native#text/pascal examples/notebk.pp svneol=native#text/pascal
examples/notebku.pp svneol=native#text/pascal examples/notebku.pp svneol=native#text/pascal
examples/notebooktest.pp svneol=native#text/pascal examples/notebooktest.pp svneol=native#text/pascal
examples/objectinspector/mainunit.lfm svneol=native#text/plain
examples/objectinspector/mainunit.lrs svneol=native#text/pascal
examples/objectinspector/mainunit.pas svneol=native#text/pascal
examples/objectinspector/oiexample.lpi svneol=native#text/plain
examples/objectinspector/oiexample.lpr svneol=native#text/pascal
examples/progressbar.pp svneol=native#text/pascal examples/progressbar.pp svneol=native#text/pascal
examples/scrollbar.pp svneol=native#text/pascal examples/scrollbar.pp svneol=native#text/pascal
examples/selection.pp svneol=native#text/pascal examples/selection.pp svneol=native#text/pascal

View File

@ -100,8 +100,7 @@ begin
AComponent:=TComponent(ANode.Data); AComponent:=TComponent(ANode.Data);
if AComponent=nil then if AComponent=nil then
RaiseGDBException('TComponentTreeView.DoSelectionChanged ANode.Data=nil'); RaiseGDBException('TComponentTreeView.DoSelectionChanged ANode.Data=nil');
if ((AComponent.Owner=nil) if (AComponent=PropertyEditorHook.LookupRoot)
and (AComponent=PropertyEditorHook.LookupRoot))
or (AComponent.Owner=PropertyEditorHook.LookupRoot) or (AComponent.Owner=PropertyEditorHook.LookupRoot)
then then
NewSelection.Add(AComponent); NewSelection.Add(AComponent);
@ -110,10 +109,10 @@ begin
end; end;
if NewSelection.IsEqual(FComponentList.Selection) then exit; if NewSelection.IsEqual(FComponentList.Selection) then exit;
FComponentList.Selection.Assign(NewSelection); FComponentList.Selection.Assign(NewSelection);
inherited DoSelectionChanged;
finally finally
NewSelection.Free; NewSelection.Free;
end; end;
inherited DoSelectionChanged;
end; end;
procedure TComponentTreeView.SetPropertyEditorHook( procedure TComponentTreeView.SetPropertyEditorHook(

View File

@ -39,7 +39,7 @@ interface
uses uses
Forms, SysUtils, Buttons, Classes, Graphics, GraphType, StdCtrls, LCLType, Forms, SysUtils, Buttons, Classes, Graphics, GraphType, StdCtrls, LCLType,
LCLLinux, LMessages, Controls, ComCtrls, ExtCtrls, TypInfo, Messages, LCLLinux, LCLProc, LMessages, Controls, ComCtrls, ExtCtrls, TypInfo, Messages,
LResources, PairSplitter, Laz_XMLCfg, Menus, Dialogs, ObjInspStrConsts, LResources, PairSplitter, Laz_XMLCfg, Menus, Dialogs, ObjInspStrConsts,
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor, PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor,
ComponentTreeView; ComponentTreeView;
@ -2451,6 +2451,7 @@ end;
procedure TObjectInspector.ComponentTreeSelectionChanged(Sender: TObject); procedure TObjectInspector.ComponentTreeSelectionChanged(Sender: TObject);
begin begin
if (PropertyEditorHook=nil) or (PropertyEditorHook.LookupRoot=nil) then exit; if (PropertyEditorHook=nil) or (PropertyEditorHook.LookupRoot=nil) then exit;
if FComponentList.IsEqual(ComponentTree.Selections) then exit;
FComponentList.Assign(ComponentTree.Selections); FComponentList.Assign(ComponentTree.Selections);
RefreshSelections; RefreshSelections;
if Assigned(FOnSelectComponentsInOI) then if Assigned(FOnSelectComponentsInOI) then

View File

@ -0,0 +1,55 @@
object Form1: TForm1
CAPTION = 'Form1'
CLIENTHEIGHT = 300
CLIENTWIDTH = 483
ONCREATE = Form1CREATE
ONDESTROY = Form1DESTROY
HORZSCROLLBAR.PAGE = 484
VERTSCROLLBAR.PAGE = 301
LEFT = 446
HEIGHT = 300
TOP = 257
WIDTH = 483
object OIGroupbox: TGROUPBOX
CAPTION = 'Root Component'
CLIENTHEIGHT = 104
CLIENTWIDTH = 172
PARENTCTL3D = False
TABORDER = 0
LEFT = 16
HEIGHT = 121
TOP = 24
WIDTH = 176
object SetOIRootFormButton: TBUTTON
CAPTION = 'Set Form as Root'
TABSTOP = True
TABORDER = 0
ONCLICK = SetOIRootFormButtonCLICK
LEFT = 15
HEIGHT = 25
TOP = 16
WIDTH = 139
end
object SetCompAsOIRootButton: TBUTTON
CAPTION = 'Set Component'
TABSTOP = True
TABORDER = 1
ONCLICK = SetCompAsOIRootButtonCLICK
LEFT = 15
HEIGHT = 25
TOP = 54
WIDTH = 139
end
end
object PropGridGroupbox: TGROUPBOX
CAPTION = 'PropertyGrid'
CLIENTHEIGHT = 244
CLIENTWIDTH = 253
PARENTCTL3D = False
TABORDER = 1
LEFT = 207
HEIGHT = 261
TOP = 24
WIDTH = 257
end
end

View File

@ -0,0 +1,19 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#7'CAPTION'#6#5'Form1'#12'CLIENTHEIGHT'#3','#1#11'CL'
+'IENTWIDTH'#3#227#1#8'ONCREATE'#7#11'Form1CREATE'#9'ONDESTROY'#7#12'Form1DES'
+'TROY'#18'HORZSCROLLBAR.PAGE'#3#228#1#18'VERTSCROLLBAR.PAGE'#3'-'#1#4'LEFT'#3
+#190#1#6'HEIGHT'#3','#1#3'TOP'#3#1#1#5'WIDTH'#3#227#1#0#9'TGROUPBOX'#10'OIGr'
+'oupbox'#7'CAPTION'#6#14'Root Component'#12'CLIENTHEIGHT'#2'h'#11'CLIENTWIDT'
+'H'#3#172#0#11'PARENTCTL3D'#8#8'TABORDER'#2#0#4'LEFT'#2#16#6'HEIGHT'#2'y'#3
+'TOP'#2#24#5'WIDTH'#3#176#0#0#7'TBUTTON'#19'SetOIRootFormButton'#7'CAPTION'#6
+#16'Set Form as Root'#7'TABSTOP'#9#8'TABORDER'#2#0#7'ONCLICK'#7#24'SetOIRoot'
+'FormButtonCLICK'#4'LEFT'#2#15#6'HEIGHT'#2#25#3'TOP'#2#16#5'WIDTH'#3#139#0#0
+#0#7'TBUTTON'#21'SetCompAsOIRootButton'#7'CAPTION'#6#13'Set Component'#7'TAB'
+'STOP'#9#8'TABORDER'#2#1#7'ONCLICK'#7#26'SetCompAsOIRootButtonCLICK'#4'LEFT'
+#2#15#6'HEIGHT'#2#25#3'TOP'#2'6'#5'WIDTH'#3#139#0#0#0#0#9'TGROUPBOX'#16'Prop'
+'GridGroupbox'#7'CAPTION'#6#12'PropertyGrid'#12'CLIENTHEIGHT'#3#244#0#11'CLI'
+'ENTWIDTH'#3#253#0#11'PARENTCTL3D'#8#8'TABORDER'#2#1#4'LEFT'#3#207#0#6'HEIGH'
+'T'#3#5#1#3'TOP'#2#24#5'WIDTH'#3#1#1#0#0#0
]);

View File

@ -0,0 +1,120 @@
unit MainUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, TypInfo, LResources, Forms, Controls, Graphics, Dialogs,
ObjectInspector, PropEdits, StdCtrls, Buttons;
type
{ TMyComponent }
TMyComponent = class(TComponent)
private
FAnInteger: integer;
procedure SetAnInteger(const AValue: integer);
public
published
property AnInteger: integer read FAnInteger write SetAnInteger;
end;
TForm1 = class(TForm)
PropGridGroupbox: TGROUPBOX;
SetCompAsOIRootButton: TBUTTON;
SetOIRootFormButton: TBUTTON;
OIGroupbox: TGROUPBOX;
PropertyGrid: TOIPropertyGrid;
procedure Form1CREATE(Sender: TObject);
procedure Form1DESTROY(Sender: TObject);
procedure SetCompAsOIRootButtonCLICK(Sender: TObject);
procedure SetOIRootFormButtonCLICK(Sender: TObject);
private
procedure SetObjectInspectorRoot(AComponent: TComponent);
public
TheObjectInspector: TObjectInspector;
ThePropertyEditorHook: TPropertyEditorHook;
ARootComponent: TMyComponent;
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.Form1CREATE(Sender: TObject);
begin
// create the PropertyEditorHook (the interface to the properties)
ThePropertyEditorHook:=TPropertyEditorHook.Create;
// create the ObjectInspector
TheObjectInspector:=TObjectInspector.Create(Application);
TheObjectInspector.PropertyEditorHook:=ThePropertyEditorHook;
TheObjectInspector.SetBounds(10,10,240,500);
// create a second Root component for demonstration
ARootComponent:=TMyComponent.Create(nil);
// create the PropertyGrid
PropertyGrid:=TOIPropertyGrid.CreateWithParams(Self,ThePropertyEditorHook
,[tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat, tkSet{, tkMethod}
, tkSString, tkLString, tkAString, tkWString, tkVariant
{, tkArray, tkRecord, tkInterface}, tkClass, tkObject, tkWChar, tkBool
, tkInt64, tkQWord],
25);
with PropertyGrid do begin
Name:='PropertyGrid';
Parent:=PropGridGroupbox;
Align:=alClient;
end;
// select the Form1 in the ObjectInspector
SetObjectInspectorRoot(Self);
end;
procedure TForm1.Form1DESTROY(Sender: TObject);
begin
// TheObjectInspector is owned by the Application and therefore destroyed
// automatically
ThePropertyEditorHook.Free;
ARootComponent.Free;
end;
procedure TForm1.SetCompAsOIRootButtonCLICK(Sender: TObject);
begin
SetObjectInspectorRoot(ARootComponent);
end;
procedure TForm1.SetOIRootFormButtonCLICK(Sender: TObject);
begin
SetObjectInspectorRoot(Self);
end;
procedure TForm1.SetObjectInspectorRoot(AComponent: TComponent);
var
Selection: TComponentSelectionList;
begin
ThePropertyEditorHook.LookupRoot:=AComponent;
Selection:=TComponentSelectionList.Create;
Selection.Add(AComponent);
TheObjectInspector.Selections:=Selection;
PropertyGrid.Selections:=Selection;
Selection.Free;
end;
{ TMyComponent }
procedure TMyComponent.SetAnInteger(const AValue: integer);
begin
if FAnInteger=AValue then exit;
FAnInteger:=AValue;
end;
initialization
{$I mainunit.lrs}
end.

View File

@ -0,0 +1,70 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="2"/>
<General>
<ProjectType Value="Application"/>
<Flags>
<SaveClosedFiles Value="False"/>
<SaveOnlyProjectUnits Value="True"/>
</Flags>
<MainUnit Value="0"/>
<ActiveEditorIndexAtStart Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<Title Value="Example for the Object Inspector"/>
</General>
<Units Count="2">
<Unit0>
<CursorPos X="6" Y="10"/>
<EditorIndex Value="3"/>
<Filename Value="oiexample.lpr"/>
<IsPartOfProject Value="True"/>
<Loaded Value="True"/>
<TopLine Value="1"/>
<UnitName Value="OIExample"/>
<UsageCount Value="21"/>
</Unit0>
<Unit1>
<CursorPos X="19" Y="68"/>
<EditorIndex Value="0"/>
<Filename Value="mainunit.pas"/>
<ComponentName Value="Form1"/>
<IsPartOfProject Value="True"/>
<Loaded Value="True"/>
<ResourceFilename Value="mainunit.lrs"/>
<TopLine Value="44"/>
<UnitName Value="MainUnit"/>
<UsageCount Value="21"/>
</Unit1>
</Units>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
</RequiredPackages>
</ProjectOptions>
<CompilerOptions>
<SearchPaths>
<OtherUnitFiles Value="$(LazarusDir)/;$(LazarusDir)/components/units/"/>
<LCLWidgetType Value="gtk"/>
<SrcPath Value="$(LazarusDir)/designer/"/>
</SearchPaths>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,14 @@
program OIExample;
{$mode objfpc}{$H+}
uses
Interfaces,
Forms, MainUnit;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.