diff --git a/ide/fpsymbol.pas b/ide/fpsymbol.pas index 64af925015..a89aa80698 100644 --- a/ide/fpsymbol.pas +++ b/ide/fpsymbol.pas @@ -126,26 +126,37 @@ type function GetPalette: PPalette; virtual; end; -{$ifdef HASOUTLINE} PSymbolInheritanceView = ^TSymbolInheritanceView; +{$ifdef HASOUTLINE} TSymbolInheritanceView = object(TOutlineViewer) +{$else notHASOUTLINE} + TSymbolInheritanceView = object(TLocalMenuListBox) +{$endif HASOUTLINE} constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar; ARoot: PObjectSymbol); destructor Done; virtual; function GetRoot: Pointer; virtual; function HasChildren(Node: Pointer): Boolean; virtual; - function GetChild(Node: Pointer; I: Integer): Pointer; virtual; - function GetNumChildren(Node: Pointer): Integer; virtual; - function GetText(Node: Pointer): String; virtual; + function GetChild(Node: Pointer; I: sw_Integer): Pointer; virtual; + function GetNumChildren(Node: Pointer): sw_Integer; virtual; + function GetNumChildrenExposed(Node: Pointer) : sw_Integer; virtual; procedure Adjust(Node: Pointer; Expand: Boolean); virtual; function IsExpanded(Node: Pointer): Boolean; virtual; - procedure Selected(I: Integer); virtual; +{$ifdef HASOUTLINE} + function GetText(Node: Pointer): String; virtual; +{$else not HASOUTLINE} + procedure ExpandAll(Node: Pointer); + function GetNode(I : sw_Integer) : Pointer; virtual; + function GetLineNode(Item : sw_Integer) : Pointer; virtual; + function GetText(Item,MaxLen: Sw_Integer): String; virtual; +{$endif HASOUTLINE} + procedure NodeSelected(P: pointer); virtual; + procedure Selected(I: sw_Integer); virtual; procedure HandleEvent(var Event: TEvent); virtual; function GetPalette: PPalette; virtual; private Root : PObjectSymbol; MyBW : PBrowserWindow; end; -{$endif HASOUTLINE} PBrowserTabItem = ^TBrowserTabItem; TBrowserTabItem = record @@ -194,9 +205,7 @@ type Sym : PSymbol; ScopeView : PSymbolScopeView; ReferenceView : PSymbolReferenceView; -{$ifdef HASOUTLINE} InheritanceView: PSymbolInheritanceView; -{$endif HASOUTLINE} MemInfoView : PSymbolMemInfoView; UnitInfoText : PSymbolMemoView; UnitInfoUsed : PSymbolScopeView; @@ -244,9 +253,7 @@ procedure CloseAllBrowsers; (TypeOf(P^)=TypeOf(TSymbolScopeView)) or (TypeOf(P^)=TypeOf(TSymbolReferenceView)) or (TypeOf(P^)=TypeOf(TSymbolMemInfoView)) or -{$ifdef HASOUTLINE} (TypeOf(P^)=TypeOf(TSymbolInheritanceView)) or -{$endif HASOUTLINE} (TypeOf(P^)=TypeOf(TSymbolMemoView))) then Message(P,evCommand,cmClose,nil); end; @@ -329,7 +336,7 @@ begin if (not assigned(symbols) or (symbols^.count=0)) and assigned(S^.Ancestor) then Symbols:=S^.Ancestor^.Items; - if (S^.Flags and sfObject)=0 then + if (S^.Flags and (sfObject or sfClass))=0 then Anc:=nil else if S^.Ancestor=nil then Anc:=ObjectTree @@ -1060,15 +1067,23 @@ end; TSymbolInheritanceView ****************************************************************************} -{$ifdef HASOUTLINE} constructor TSymbolInheritanceView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar; ARoot: PObjectSymbol); begin +{$ifdef HASOUTLINE} inherited Init(Bounds,AHScrollBar,AVScrollBar); +{$else not HASOUTLINE} + inherited Init(Bounds,1,AVScrollBar); + HScrollBar:=AHScrollBar; +{$endif not HASOUTLINE} Options:=Options or (ofSelectable+ofTopSelect); Root:=ARoot; MyBW:=nil; - ExpandAll(GetRoot); + ExpandAll(Root); +{$ifdef HASOUTLINE} Update; +{$else not HASOUTLINE} + SetRange(GetNumChildrenExposed(Root)); +{$endif not HASOUTLINE} end; destructor TSymbolInheritanceView.Done; @@ -1090,21 +1105,42 @@ begin HasChildren:=GetNumChildren(Node)>0; end; -function TSymbolInheritanceView.GetChild(Node: Pointer; I: Integer): Pointer; +function TSymbolInheritanceView.GetChild(Node: Pointer; I: sw_Integer): Pointer; begin GetChild:=PObjectSymbol(Node)^.GetDescendant(I); end; -function TSymbolInheritanceView.GetNumChildren(Node: Pointer): Integer; +function TSymbolInheritanceView.GetNumChildren(Node: Pointer): sw_Integer; begin GetNumChildren:=PObjectSymbol(Node)^.GetDescendantCount; end; -function TSymbolInheritanceView.GetText(Node: Pointer): String; +function TSymbolInheritanceView.GetNumChildrenExposed(Node: Pointer) : sw_Integer; +var + Nb : integer; + P : PObjectSymbol; + Procedure AddCount(P : PObjectSymbol); + var + i,count : integer; + D : PObjectSymbol; + begin + if not assigned(P) then + exit; + Count:=P^.GetDescendantCount; + Inc(Nb,Count); + for I:=0 to Count-1 do + begin + D:=P^.GetDescendant(I); + AddCount(D); + end; + end; begin - GetText:=PObjectSymbol(Node)^.GetName; + Nb:=0; + AddCount(Node); + GetNumChildrenExposed:=Nb; end; + procedure TSymbolInheritanceView.Adjust(Node: Pointer; Expand: Boolean); begin PObjectSymbol(Node)^.Expanded:=Expand; @@ -1117,12 +1153,19 @@ end; procedure TSymbolInheritanceView.HandleEvent(var Event: TEvent); var DontClear: boolean; +{$ifndef HASOUTLINE} + P: TPoint; +{$endif HASOUTLINE} begin case Event.What of evKeyDown : begin DontClear:=false; case Event.KeyCode of +{$ifndef HASOUTLINE} + kbEnter: + NodeSelected(GetLineNode(Cursor.Y-Origin.Y)); +{$endif HASOUTLINE} kbLeft,kbRight, kbCtrlLeft,kbCtrlRight : if Assigned(HScrollBar) then @@ -1135,6 +1178,10 @@ begin end; evMouseDown : begin +{$ifndef HASOUTLINE} + MakeLocal(Event.Where,P); + SetCursor(P.X,P.Y); +{$endif HASOUTLINE} if Event.double then begin Message(@Self,evKeyDown,kbEnter,nil); @@ -1151,13 +1198,151 @@ begin GetPalette:=@P; end; -procedure TSymbolInheritanceView.Selected(I: Integer); +{$ifdef HASOUTLINE} +function TSymbolInheritanceView.GetText(Node: Pointer): String; +begin + GetText:=PObjectSymbol(Node)^.GetName; +end; + +{$else not HASOUTLINE} +function TSymbolInheritanceView.GetNode(I : sw_Integer) : Pointer; +var + P : PObjectSymbol; +begin + P:=Root; + If Assigned(P) then + P:=P^.GetDescendant(I); + GetNode:=Pointer(P); +end; + +procedure TSymbolInheritanceView.ExpandAll(Node: Pointer); +var + i : integer; + P : Pointer; +begin + Adjust(Node,true); + For i:=0 to GetNumChildren(Node)-1 do + begin + P:=GetChild(Node,I); + if Assigned(P) then + ExpandAll(P); + end; +end; + +function TSymbolInheritanceView.GetLineNode(Item : sw_Integer) : Pointer; +var + P : PObjectSymbol; + NT: Integer; + procedure FindSymbol(var P:PObjectSymbol); + var + Q : PObjectSymbol; + Nc,Des : integer; + begin + if not assigned(P) then + exit; + Des:=0; + While (NT0) or (Pos('var',Sym^.GetText)>0) then Tabs:=Tabs or (1 shl btBreakWatch); -{$endif NODEBUG} +{$endif NODEBUG} if assigned(UnitInfo) then Tabs:=Tabs or (1 shl btUnitInfo); if PageTab<>nil then PageTab^.SetParams(Tabs,BrowserTab);