mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 10:26:06 +02:00
* Further development
git-svn-id: trunk@3693 -
This commit is contained in:
parent
86d9e04409
commit
bf2950a809
@ -27,7 +27,7 @@ type Pnode=^Tnode;
|
|||||||
procedure expandall(node:pointer);
|
procedure expandall(node:pointer);
|
||||||
function firstthat(test:pointer):pointer;
|
function firstthat(test:pointer):pointer;
|
||||||
procedure focused(i:sw_integer);virtual;
|
procedure focused(i:sw_integer);virtual;
|
||||||
procedure foreach(node:pointer);
|
procedure foreach(action:pointer);
|
||||||
function getchild(node:pointer;i:sw_integer):pointer;virtual;
|
function getchild(node:pointer;i:sw_integer):pointer;virtual;
|
||||||
function getgraph(level:integer;lines:longint;flags:word):string;
|
function getgraph(level:integer;lines:longint;flags:word):string;
|
||||||
function getnode(i:sw_integer):pointer;virtual;
|
function getnode(i:sw_integer):pointer;virtual;
|
||||||
@ -36,7 +36,12 @@ type Pnode=^Tnode;
|
|||||||
function gettext(node:pointer):string;virtual;
|
function gettext(node:pointer):string;virtual;
|
||||||
function haschildren(node:pointer):boolean;virtual;
|
function haschildren(node:pointer):boolean;virtual;
|
||||||
function isexpanded(node:pointer):boolean;virtual;
|
function isexpanded(node:pointer):boolean;virtual;
|
||||||
destructor done;virtual;
|
function isselected(i:sw_integer):boolean;virtual;
|
||||||
|
procedure selected(i:sw_integer);virtual;
|
||||||
|
procedure setstate(Astate:word;enable:boolean);virtual;
|
||||||
|
procedure update;
|
||||||
|
private
|
||||||
|
procedure set_focus(Afocus:sw_integer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Toutline=object(Toutlineviewer)
|
Toutline=object(Toutlineviewer)
|
||||||
@ -51,11 +56,13 @@ type Pnode=^Tnode;
|
|||||||
function gettext(node:pointer):string;virtual;
|
function gettext(node:pointer):string;virtual;
|
||||||
function haschildren(node:pointer):boolean;virtual;
|
function haschildren(node:pointer):boolean;virtual;
|
||||||
function isexpanded(node:pointer):boolean;virtual;
|
function isexpanded(node:pointer):boolean;virtual;
|
||||||
function isselected(node:pointer):boolean;virtual;
|
destructor done;virtual;
|
||||||
procedure selected(i:sw_integer);virtual;
|
|
||||||
procedure setstate(Astate:word;enable:boolean);virtual;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
const ovExpanded = $1;
|
||||||
|
ovChildren = $2;
|
||||||
|
ovLast = $4;
|
||||||
|
|
||||||
function newnode(const Atext:string;Achildren,Anext:Pnode):Pnode;
|
function newnode(const Atext:string;Achildren,Anext:Pnode):Pnode;
|
||||||
procedure disposenode(node:Pnode);
|
procedure disposenode(node:Pnode);
|
||||||
|
|
||||||
@ -85,15 +92,13 @@ end;
|
|||||||
procedure disposenode(node:Pnode);
|
procedure disposenode(node:Pnode);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
with node^ do
|
while node<>nil do
|
||||||
begin
|
begin
|
||||||
if childlist<>nil then
|
disposenode(node^.childlist);
|
||||||
disposenode(childlist);
|
disposestr(node^.text);
|
||||||
if next<>nil then
|
dispose(node);
|
||||||
disposenode(next)
|
node:=node^.next;
|
||||||
disposestr(text);
|
|
||||||
end;
|
end;
|
||||||
dispose(node);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
|
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
|
||||||
@ -109,7 +114,7 @@ begin
|
|||||||
growmode:=gfGrowHiX+gfGrowHiY;
|
growmode:=gfGrowHiX+gfGrowHiY;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Toutlineviewer.adjust(node:pointer;expand:boolean);virtual;
|
procedure Toutlineviewer.adjust(node:pointer;expand:boolean);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
abstract;
|
abstract;
|
||||||
@ -277,10 +282,10 @@ begin
|
|||||||
abstract;
|
abstract;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Toutlineviewer.isexpanded(i:sw_integer):boolean;
|
function Toutlineviewer.isselected(i:sw_integer):boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
isexpanded:=foc=i;
|
isselected:=foc=i;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Toutlineviewer.selected(i:sw_integer);
|
procedure Toutlineviewer.selected(i:sw_integer);
|
||||||
@ -289,14 +294,44 @@ begin
|
|||||||
{Does nothing by default.}
|
{Does nothing by default.}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure Toutlineviewer.set_focus(Afocus:sw_integer);
|
||||||
|
|
||||||
|
begin
|
||||||
|
{}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Toutlineviewer.setstate(Astate:word;enable:boolean);
|
procedure Toutlineviewer.setstate(Astate:word;enable:boolean);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Astate and sffocused<>0 then
|
if Astate and sffocused<>0 then
|
||||||
drawview;
|
drawview;
|
||||||
inherited setstate(Astate);
|
inherited setstate(Astate,enable);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure Toutlineviewer.update;
|
||||||
|
|
||||||
|
var count:sw_integer;
|
||||||
|
maxwidth:byte;
|
||||||
|
|
||||||
|
procedure check_item(cur:pointer;level,position:sw_integer;
|
||||||
|
lines:longint;flags:word);
|
||||||
|
|
||||||
|
var width:word;
|
||||||
|
|
||||||
|
begin
|
||||||
|
inc(count);
|
||||||
|
width:=length(gettext(cur))+length(getgraph(level,lines,flags));
|
||||||
|
if width>maxwidth then
|
||||||
|
maxwidth:=width;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
count:=0;
|
||||||
|
maxwidth:=0;
|
||||||
|
foreach(@check_item);
|
||||||
|
setlimit(maxwidth,count);
|
||||||
|
set_focus(foc);
|
||||||
|
end;
|
||||||
|
|
||||||
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
|
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
|
||||||
{ Toutline object methods }
|
{ Toutline object methods }
|
||||||
@ -308,7 +343,7 @@ constructor Toutline.init(var bounds:Trect;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
inherited init(bounds,AHscrollbar,AVscrollbar);
|
inherited init(bounds,AHscrollbar,AVscrollbar);
|
||||||
root:=Pnode;
|
root:=Aroot;
|
||||||
update;
|
update;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -318,38 +353,32 @@ begin
|
|||||||
Pnode(node)^.expanded:=expand;
|
Pnode(node)^.expanded:=expand;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Toutline.getroot:pointer;virtual;
|
function Toutline.getnumchildren(node:pointer):sw_integer;
|
||||||
|
|
||||||
begin
|
|
||||||
getroot:=root;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function Toutline.getnumchildren(node:pointer):sw_integer;virtual;
|
|
||||||
|
|
||||||
var p:Pnode;
|
var p:Pnode;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
p:=Pnode(node)^.childlist;
|
p:=Pnode(node)^.childlist;
|
||||||
get_num_children:=0;
|
getnumchildren:=0;
|
||||||
while p<>nil do
|
while p<>nil do
|
||||||
begin
|
begin
|
||||||
inc(get_num_children);
|
inc(getnumchildren);
|
||||||
p:=p^.next;
|
p:=p^.next;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Toutline.getchild(node:pointer;i:sw_integer):pointer;virtual;
|
function Toutline.getchild(node:pointer;i:sw_integer):pointer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
get_child:=Pnode(node)^.childlist;
|
getchild:=Pnode(node)^.childlist;
|
||||||
while i<>0 do
|
while i<>0 do
|
||||||
begin
|
begin
|
||||||
dec(i);
|
dec(i);
|
||||||
get_child:=get_child^.next;
|
getchild:=Pnode(getchild)^.next;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Toutlineviewer.getroot:pointer;
|
function Toutline.getroot:pointer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
getroot:=root;
|
getroot:=root;
|
||||||
@ -358,7 +387,7 @@ end;
|
|||||||
function Toutline.gettext(node:pointer):string;
|
function Toutline.gettext(node:pointer):string;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
gettext:=Pnode(node)^.text;
|
gettext:=Pnode(node)^.text^;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Toutline.haschildren(node:pointer):boolean;
|
function Toutline.haschildren(node:pointer):boolean;
|
||||||
@ -367,7 +396,7 @@ begin
|
|||||||
haschildren:=Pnode(node)^.childlist<>nil;
|
haschildren:=Pnode(node)^.childlist<>nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function isexpanded(node:pointer):boolean;
|
function Toutline.isexpanded(node:pointer):boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
isexpanded:=Pnode(node)^.expanded;
|
isexpanded:=Pnode(node)^.expanded;
|
||||||
@ -376,7 +405,8 @@ end;
|
|||||||
destructor Toutline.done;
|
destructor Toutline.done;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
dispose(root,done);
|
disposenode(root);
|
||||||
|
inherited done;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user