|
1 ToolApplicationModel subclass:#HTMLBrowser |
|
2 instanceVariableNames:'' |
|
3 classVariableNames:'' |
|
4 poolDictionaries:'' |
|
5 category:'Interface-Browsers' |
|
6 ! |
|
7 |
|
8 HTMLBrowser class instanceVariableNames:'lastFileName' |
|
9 |
|
10 " |
|
11 The following class instance variables are inherited by this class: |
|
12 |
|
13 ToolApplicationModel - history clipboard showHelp |
|
14 ApplicationModel - ClassResources |
|
15 Model - |
|
16 Object - |
|
17 " |
|
18 ! |
|
19 |
|
20 !HTMLBrowser class methodsFor:'documentation'! |
|
21 |
|
22 documentation |
|
23 " |
|
24 The future HTML Browser. |
|
25 |
|
26 [author:] |
|
27 Thomas Zwick, eXept Software AG |
|
28 " |
|
29 ! ! |
|
30 |
|
31 !HTMLBrowser class methodsFor:'accessing'! |
|
32 |
|
33 lastFileName |
|
34 |
|
35 ^lastFileName |
|
36 ! |
|
37 |
|
38 lastFileName: aFileName |
|
39 |
|
40 ^lastFileName := aFileName |
|
41 ! ! |
|
42 |
|
43 !HTMLBrowser class methodsFor:'history'! |
|
44 |
|
45 historyMaxSize |
|
46 |
|
47 ^25 |
|
48 |
|
49 ! ! |
|
50 |
|
51 !HTMLBrowser class methodsFor:'interface specs'! |
|
52 |
|
53 windowSpec |
|
54 "this window spec was automatically generated by the ST/X UIPainter" |
|
55 |
|
56 "do not manually edit this - the painter/builder may not be able to |
|
57 handle the specification if its corrupted." |
|
58 |
|
59 " |
|
60 UIPainter new openOnClass:HTMLBrowser andSelector:#windowSpec |
|
61 HTMLBrowser new openInterface:#windowSpec |
|
62 " |
|
63 "HTMLBrowser open" |
|
64 |
|
65 <resource: #canvas> |
|
66 |
|
67 ^ |
|
68 |
|
69 #(#FullSpec |
|
70 #'window:' |
|
71 #(#WindowSpec |
|
72 #'name:' 'HTML Browser' |
|
73 #'layout:' #(#LayoutFrame 385 0 376 0 684 0 675 0) |
|
74 #'label:' 'HTML Browser' |
|
75 #'min:' #(#Point 10 10) |
|
76 #'max:' #(#Point 1152 864) |
|
77 #'bounds:' #(#Rectangle 385 376 685 676) |
|
78 #'menu:' #menu |
|
79 #'usePreferredExtent:' false |
|
80 ) |
|
81 #'component:' |
|
82 #(#SpecCollection |
|
83 #'collection:' |
|
84 #( |
|
85 #(#MenuPanelSpec |
|
86 #'name:' 'menuToolbarView' |
|
87 #'layout:' #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
88 #'menu:' #menuToolbar |
|
89 #'showSeparatingLines:' true |
|
90 ) |
|
91 #(#HTMLViewSpec |
|
92 #'name:' 'htmlView' |
|
93 #'layout:' #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0) |
|
94 #'model:' #valueOfHTMLDocument |
|
95 #'hasHorizontalScrollBar:' true |
|
96 #'hasVerticalScrollBar:' true |
|
97 ) |
|
98 #(#UISubSpecification |
|
99 #'name:' 'uISubSpecification1' |
|
100 #'layout:' #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
101 #'majorKey:' #ToolApplicationModel |
|
102 #'minorKey:' #windowSpecForInfoBarWithClock |
|
103 ) |
|
104 ) |
|
105 ) |
|
106 ) |
|
107 ! ! |
|
108 |
|
109 !HTMLBrowser class methodsFor:'menu specs'! |
|
110 |
|
111 menu |
|
112 "this window spec was automatically generated by the ST/X MenuEditor" |
|
113 |
|
114 "do not manually edit this - the builder may not be able to |
|
115 handle the specification if its corrupted." |
|
116 |
|
117 " |
|
118 MenuEditor new openOnClass:HTMLBrowser andSelector:#menu |
|
119 (Menu new fromLiteralArrayEncoding:(HTMLBrowser menu)) startUp |
|
120 " |
|
121 |
|
122 <resource: #menu> |
|
123 |
|
124 ^ |
|
125 |
|
126 #(#Menu |
|
127 |
|
128 #( |
|
129 #(#MenuItem |
|
130 #'label:' 'About' |
|
131 #'activeHelpKey:' #about |
|
132 #'accessCharacterPosition:' 1 |
|
133 #'labelImage:' #(#ResourceRetriever nil #menuIcon) |
|
134 #'submenuChannel:' #menuAbout |
|
135 ) |
|
136 #(#MenuItem |
|
137 #'label:' 'File' |
|
138 #'translateLabel:' true |
|
139 #'activeHelpKey:' #file |
|
140 #'submenu:' |
|
141 #(#Menu |
|
142 |
|
143 #( |
|
144 #(#MenuItem |
|
145 #'label:' 'Load...' |
|
146 #'translateLabel:' true |
|
147 #'value:' #doLoad |
|
148 #'activeHelpKey:' #fileLoad |
|
149 #'enabled:' #isStandAlone |
|
150 ) |
|
151 #(#MenuItem |
|
152 #'label:' '-' |
|
153 ) |
|
154 #(#MenuItem |
|
155 #'label:' 'Print' |
|
156 #'value:' #'doPerform:' |
|
157 #'argument:' #'menu_print' |
|
158 ) |
|
159 #(#MenuItem |
|
160 #'label:' '-' |
|
161 ) |
|
162 #(#MenuItem |
|
163 #'label:' 'Exit' |
|
164 #'translateLabel:' true |
|
165 #'value:' #closeRequest |
|
166 #'activeHelpKey:' #fileExit |
|
167 ) |
|
168 ) nil |
|
169 nil |
|
170 ) |
|
171 ) |
|
172 #(#MenuItem |
|
173 #'label:' 'Navigate' |
|
174 #'submenuChannel:' #menuNavigate |
|
175 ) |
|
176 #(#MenuItem |
|
177 #'label:' 'Misc' |
|
178 #'submenu:' |
|
179 #(#Menu |
|
180 |
|
181 #( |
|
182 #(#MenuItem |
|
183 #'label:' 'Source...' |
|
184 #'value:' #'doPerform:' |
|
185 #'argument:' #'menu_source' |
|
186 ) |
|
187 #(#MenuItem |
|
188 #'label:' '-' |
|
189 ) |
|
190 #(#MenuItem |
|
191 #'label:' 'Settings...' |
|
192 #'value:' #'doPerform:' |
|
193 #'argument:' #'menu_settings' |
|
194 ) |
|
195 ) nil |
|
196 nil |
|
197 ) |
|
198 ) |
|
199 #(#MenuItem |
|
200 #'label:' 'History' |
|
201 #'activeHelpKey:' #history |
|
202 #'submenuChannel:' #menuHistory |
|
203 ) |
|
204 #(#MenuItem |
|
205 #'label:' 'Help' |
|
206 #'startGroup:' #right |
|
207 #'activeHelpKey:' #help |
|
208 #'submenuChannel:' #menuHelp |
|
209 ) |
|
210 ) nil |
|
211 nil |
|
212 ) |
|
213 ! |
|
214 |
|
215 menuNavigate |
|
216 "this window spec was automatically generated by the ST/X MenuEditor" |
|
217 |
|
218 "do not manually edit this - the builder may not be able to |
|
219 handle the specification if its corrupted." |
|
220 |
|
221 " |
|
222 MenuEditor new openOnClass:HTMLBrowser andSelector:#menuNavigate |
|
223 (Menu new fromLiteralArrayEncoding:(HTMLBrowser menuNavigate)) startUp |
|
224 " |
|
225 |
|
226 <resource: #menu> |
|
227 |
|
228 ^ |
|
229 |
|
230 #(#Menu |
|
231 |
|
232 #( |
|
233 #(#MenuItem |
|
234 #'label:' 'Next' |
|
235 #'value:' #'doPerform:' |
|
236 #'enabled:' #valueOfCanNavigateToNext |
|
237 #'argument:' '1' |
|
238 #'labelImage:' #(#ResourceRetriever nil #rightIcon 'Next') |
|
239 ) |
|
240 #(#MenuItem |
|
241 #'label:' 'Previous' |
|
242 #'value:' #'doPerform:' |
|
243 #'enabled:' #valueOfCanNavigateToPrevious |
|
244 #'argument:' '-1' |
|
245 #'labelImage:' #(#ResourceRetriever nil #leftIcon 'Previous') |
|
246 ) |
|
247 #(#MenuItem |
|
248 #'label:' '-' |
|
249 ) |
|
250 #(#MenuItem |
|
251 #'label:' 'Home' |
|
252 #'value:' #'doPerform:' |
|
253 #'argument:' #'menu_home' |
|
254 ) |
|
255 #(#MenuItem |
|
256 #'label:' 'Back' |
|
257 #'value:' #'doPerform:' |
|
258 #'argument:' #'menu_back' |
|
259 ) |
|
260 #(#MenuItem |
|
261 #'label:' 'Reload' |
|
262 #'value:' #'doPerform:' |
|
263 #'argument:' #'menu_reload' |
|
264 ) |
|
265 ) nil |
|
266 nil |
|
267 ) |
|
268 ! |
|
269 |
|
270 menuToolbar |
|
271 "this window spec was automatically generated by the ST/X MenuEditor" |
|
272 |
|
273 "do not manually edit this - the builder may not be able to |
|
274 handle the specification if its corrupted." |
|
275 |
|
276 " |
|
277 MenuEditor new openOnClass:HTMLBrowser andSelector:#menuToolbar |
|
278 (Menu new fromLiteralArrayEncoding:(HTMLBrowser menuToolbar)) startUp |
|
279 " |
|
280 |
|
281 <resource: #menu> |
|
282 |
|
283 ^ |
|
284 |
|
285 #(#Menu |
|
286 |
|
287 #( |
|
288 #(#MenuItem |
|
289 #'label:' 'Load' |
|
290 #'isButton:' true |
|
291 #'value:' #doLoad |
|
292 #'labelImage:' #(#ResourceRetriever nil #loadIcon) |
|
293 ) |
|
294 #(#MenuItem |
|
295 #'label:' '' |
|
296 ) |
|
297 #(#MenuItem |
|
298 #'label:' 'Next' |
|
299 #'isButton:' true |
|
300 #'value:' #'doPerform:' |
|
301 #'enabled:' #valueOfCanNavigateToNext |
|
302 #'argument:' '1' |
|
303 #'labelImage:' #(#ResourceRetriever nil #rightIcon) |
|
304 ) |
|
305 #(#MenuItem |
|
306 #'label:' 'Previous' |
|
307 #'isButton:' true |
|
308 #'value:' #'doPerform:' |
|
309 #'enabled:' #valueOfCanNavigateToPrevious |
|
310 #'argument:' '-1' |
|
311 #'labelImage:' #(#ResourceRetriever nil #leftIcon) |
|
312 ) |
|
313 ) nil |
|
314 nil |
|
315 ) |
|
316 ! ! |
|
317 |
|
318 !HTMLBrowser methodsFor:'accessing - views'! |
|
319 |
|
320 htmlViewDoc |
|
321 |
|
322 ^(builder componentAt: #htmlView) scrolledView |
|
323 ! ! |
|
324 |
|
325 !HTMLBrowser methodsFor:'aspects'! |
|
326 |
|
327 valueOfCanNavigateToNext |
|
328 |
|
329 |holder| |
|
330 |
|
331 (holder := builder bindingAt:#valueOfCanNavigateToNext) isNil ifTrue:[ |
|
332 builder aspectAt:#valueOfCanNavigateToNext put:(holder := false asValue). |
|
333 ]. |
|
334 ^ holder |
|
335 ! |
|
336 |
|
337 valueOfCanNavigateToPrevious |
|
338 |
|
339 |holder| |
|
340 |
|
341 (holder := builder bindingAt:#valueOfCanNavigateToPrevious) isNil ifTrue:[ |
|
342 builder aspectAt:#valueOfCanNavigateToPrevious put:(holder := false asValue). |
|
343 ]. |
|
344 ^ holder |
|
345 ! |
|
346 |
|
347 valueOfHTMLDocument |
|
348 |
|
349 |holder| |
|
350 |
|
351 (holder := builder bindingAt:#valueOfHTMLDocument) isNil ifTrue:[ |
|
352 builder aspectAt:#valueOfHTMLDocument put:(holder := ValueHolder new). |
|
353 ]. |
|
354 ^ holder |
|
355 ! ! |
|
356 |
|
357 !HTMLBrowser methodsFor:'help'! |
|
358 |
|
359 openTutorial |
|
360 |
|
361 self doPerform: #menu_help |
|
362 |
|
363 ! ! |
|
364 |
|
365 !HTMLBrowser methodsFor:'startup / release'! |
|
366 |
|
367 postOpenWith:aBuilder |
|
368 |
|
369 self loadFromFile: self class lastFileName. |
|
370 self htmlViewDoc history addAll: self historyEntries. |
|
371 self updateChannels. |
|
372 super postOpenWith:aBuilder. |
|
373 |
|
374 ! ! |
|
375 |
|
376 !HTMLBrowser methodsFor:'user actions'! |
|
377 |
|
378 doLoad |
|
379 |
|
380 self loadFromFile: |
|
381 (FileSelectionBrowser request: 'Load a HTML File' fileFilters: #('.htm' '*.html')) |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 ! |
|
388 |
|
389 doPerform: what |
|
390 |
|
391 (self htmlViewDoc respondsTo: what) |
|
392 ifTrue: |
|
393 [ |
|
394 self htmlViewDoc perform: what. |
|
395 self valueOfHTMLDocument value: self htmlViewDoc currentURL. |
|
396 self class lastFileName: self htmlViewDoc currentURL |
|
397 ] |
|
398 ifFalse: |
|
399 [ |
|
400 self valueOfHTMLDocument value: |
|
401 (self class lastFileName: (self htmlViewDoc history at: |
|
402 (self htmlViewDoc history indexOf: self valueOfHTMLDocument value) + what asInteger ifAbsent: [self class lastFileName])). |
|
403 ]. |
|
404 |
|
405 self updateChannels |
|
406 ! |
|
407 |
|
408 loadFromFile: aFileName |
|
409 |
|
410 self valueOfHTMLDocument value: aFileName. |
|
411 aFileName notNil |
|
412 ifTrue: |
|
413 [ |
|
414 self class lastFileName: aFileName |
|
415 ]. |
|
416 |
|
417 self updateChannels |
|
418 ! |
|
419 |
|
420 updateChannels |
|
421 |
|
422 |htmlViewDoc| |
|
423 htmlViewDoc := self htmlViewDoc. |
|
424 (htmlViewDoc history at: |
|
425 (htmlViewDoc history indexOf: self valueOfHTMLDocument value) + 1 |
|
426 ifAbsent: nil) isNil |
|
427 ifTrue: [self valueOfCanNavigateToNext value: false] |
|
428 ifFalse: [self valueOfCanNavigateToNext value: true]. |
|
429 |
|
430 (htmlViewDoc history at: |
|
431 (htmlViewDoc history indexOf: self valueOfHTMLDocument value) - 1 |
|
432 ifAbsent: nil) isNil |
|
433 ifTrue: [self valueOfCanNavigateToPrevious value: false] |
|
434 ifFalse: [self valueOfCanNavigateToPrevious value: true]. |
|
435 |
|
436 "self emptyHistory." |
|
437 htmlViewDoc history do: [:url| self addToHistory: url -> #loadFromFile:]. |
|
438 ! ! |
|
439 |
|
440 !HTMLBrowser class methodsFor:'documentation'! |
|
441 |
|
442 version |
|
443 ^ '$Header$' |
|
444 ! ! |