source: trunk/NewView/NavigatePointUnit.pas@ 33

Last change on this file since 33 was 33, checked in by RBRi, 19 years ago

more uses cleanup

  • Property svn:eol-style set to native
File size: 4.3 KB
Line 
1Unit NavigatePointUnit;
2
3// NewView - a new OS/2 Help Viewer
4// Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
5// This software is released under the Gnu Public License - see readme.txt
6
7Interface
8
9uses
10 Classes,
11 HelpFile,
12 HelpTopic,
13 HelpWindowDimensions;
14
15type
16 // Navigate point: a saved history position specifiying
17 // a set of windows that were displayed.
18 TNavigatePoint = class
19 ContentsTopic: TTopic;
20 Windows: TList;
21 constructor Create;
22 destructor Destroy; Override;
23 procedure Save( Var F: TextFile );
24 constructor Load( Var F: TextFile; HelpFile: THelpFile );
25 end;
26
27 // A help window definition as saved in a navigate point
28 TSavedHelpWindow = class
29 Topic: TTopic;
30 Group: longint;
31
32 ChildWindows: TList;
33 Parent: TSavedHelpWindow;
34
35 Rect: THelpWindowRect;
36
37 TopCharIndex: longint; // used when saving for navigation
38
39 constructor Create;
40 destructor Destroy; override;
41 procedure Save( Var F: TextFile; Prefix: string; );
42 constructor Load( Var F: TextFile; HelpFile: THelpFile );
43 end;
44
45Implementation
46
47uses
48 SysUtils,
49 ACLUtility,
50 ACLStringUtility;
51
52procedure SaveWindowList( Var F: TextFile;
53 Windows: TList;
54 Prefix: string );
55var
56 i: integer;
57 Window: TSavedHelpWindow;
58 S: string;
59begin
60 S := Prefix + IntToStr( Windows.Count );
61 WriteLn( F, S );
62 for i := 0 to Windows.Count - 1 do
63 begin
64 Window := Windows[ i ];
65 Window.Save( F, Prefix + ' ' );
66 end;
67end;
68
69procedure LoadWindowList( Var F: TextFile;
70 Windows: TList;
71 HelpFile: THelpFile );
72var
73 i: integer;
74 Window: TSavedHelpWindow;
75 WindowCount: integer;
76 S: string;
77begin
78 ReadLn( F, S );
79 try
80 WindowCount := StrToInt( S );
81 except
82 WindowCount := 0;
83 end;
84 for i := 0 to WindowCount - 1 do
85 begin
86 Window := TSavedHelpWindow.Load( F, HelpFile );
87 Windows.Add( Window );
88 end;
89end;
90
91// --- TNavigatePoint ---------------------------------
92
93constructor TNavigatePoint.Create;
94begin
95 inherited Create;
96 ContentsTopic:= nil;
97 Windows:= TList.Create;
98end;
99
100destructor TNavigatePoint.Destroy;
101begin
102 inherited Destroy;
103 DestroyListObjects( Windows );
104 Windows.Destroy;
105end;
106
107procedure TNavigatePoint.Save( Var F: TextFile );
108begin
109 WriteLn( F, IntToStr( ContentsTopic.Index ) );
110 SaveWindowList( F, Windows, '' );
111end;
112
113constructor TNavigatePoint.Load( Var F: Text;
114 HelpFile: THelpFile );
115Var
116 s: string;
117 ContentsTopicIndex: integer;
118begin
119 inherited Create;
120 ReadLn( F, S );
121 ContentsTopicIndex := StrToInt( S );
122 ContentsTopic:= HelpFile.Topics[ ContentsTopicIndex ];
123
124 Windows:= TList.Create;
125 LoadWindowList( F, Windows, HelpFile );
126end;
127
128// --- TSavedHelpWindow ---------------------------------
129
130constructor TSavedHelpWindow.Create;
131begin
132 inherited Create;
133 ChildWindows:= TList.Create;
134 Rect:= THelpWindowRect.Create;
135end;
136
137destructor TSavedHelpWindow.Destroy;
138begin
139 DestroyListObjects( ChildWindows );
140 ChildWindows.Destroy;
141 Rect.Destroy;
142 inherited Destroy;
143end;
144
145procedure TSavedHelpWindow.Save( Var F: TextFile;
146 Prefix: string );
147begin
148 WriteLn( F,
149 Prefix
150 + IntToStr( Topic.Index )
151 + ', '
152 + IntToStr( Group )
153 + ', '
154 + IntToStr( Rect.Left )
155 + ', '
156 + IntToStr( Rect.Bottom )
157 + ', '
158 + IntToStr( Rect.Width )
159 + ', '
160 + IntToStr( Rect.Height )
161 + ', '
162 + IntToStr( TopCharIndex )
163 );
164 SaveWindowList( F, ChildWindows, Prefix );
165end;
166
167constructor TSavedHelpWindow.Load( Var F: TextFile );
168var
169 s: string;
170 TopicIndex: integer;
171begin
172 inherited Create;
173 ChildWindows:= TList.Create;
174 Rect:= THelpWindowRect.Create;
175
176 ReadLn( F, S );
177
178 TopicIndex := StrToInt( ExtractNextValue( S, ',' ) );
179 Topic := HelpFile.Topics[ TopicIndex ];
180 Group := StrToInt( ExtractNextValue( S, ',' ) );
181 Rect.Left := StrToInt( ExtractNextValue( S, ',' ) );
182 Rect.Bottom := StrToInt( ExtractNextValue( S, ',' ) );
183 Rect.Width := StrToInt( ExtractNextValue( S, ',' ) );
184 Rect.Height := StrToInt( ExtractNextValue( S, ',' ) );
185 TopCharIndex := StrToInt( ExtractNextValue( S, ',' ) );
186
187 LoadWindowList( F, ChildWindows, HelpFile );
188end;
189
190Initialization
191End.
Note: See TracBrowser for help on using the repository browser.