306 ^ (selectionList directory pathName asFilename construct:string) asString |
306 ^ (selectionList directory pathName asFilename construct:string) asString |
307 |
307 |
308 "Modified: / 9.9.1998 / 21:23:16 / cg" |
308 "Modified: / 9.9.1998 / 21:23:16 / cg" |
309 ! |
309 ! |
310 |
310 |
311 ied: / 9.9.1998 / 21:23:16 / cg" |
311 directory |
312 ! |
312 "return the directory which is currently shown" |
313 |
313 |
314 ^ selectionList directory |
314 ^ selectionList directory |
315 ! |
315 ! |
316 |
316 |
317 tionList directory:directoryName |
317 directory:directoryName |
318 ! |
318 "change the directory shown in the list." |
319 |
319 |
320 ed: / 12.8.1998 / 09:54:01 / cg" |
320 selectionList directory:directoryName |
321 ! |
321 ! |
322 |
322 |
323 selectionList matchBlock:aBlock |
323 fileName |
|
324 "if some filename has been entered, return it (without the directory path) |
|
325 otherwise, return nil" |
|
326 |
|
327 |string| |
|
328 |
|
329 string := super contents. |
|
330 string isNil ifTrue:[^ nil]. |
|
331 ^ self pathName asFilename baseName |
|
332 |
|
333 "Modified: / 12.8.1998 / 09:54:01 / cg" |
|
334 ! |
|
335 |
|
336 matchBlock:aBlock |
|
337 "set the matchBlock (in the selectionList). Only files |
|
338 for which the block returns true are shown. |
|
339 The matching is actually done in the fileSelectionList." |
|
340 |
|
341 selectionList matchBlock:aBlock |
|
342 ! |
|
343 |
|
344 openOn:aPath |
|
345 "open the box showing files in aPath. |
|
346 This is only a shortcut message - no new functionality." |
|
347 |
|
348 self directory:aPath. |
|
349 self showAtPointer |
324 ! |
350 ! |
325 |
351 |
326 pathName |
352 pathName |
327 "same as contents - return the full pathname of the selected file, |
353 "same as contents - return the full pathname of the selected file, |
328 or the pathname of the directory if nothing has been entered" |
354 or the pathname of the directory if nothing has been entered" |
329 |
355 |
330 ^ self contents |
356 ^ self contents |
331 ! |
357 ! |
332 |
358 |
333 entered" |
359 pattern:aPattern |
334 |
360 "set the pattern - this also enables the PatternField |
335 ^ self contents |
361 (if the pattern is non-nil) or hides it (if nil)." |
|
362 |
|
363 |focusSequence| |
|
364 |
|
365 patternField initialText:aPattern. |
|
366 selectionList pattern:aPattern. |
|
367 aPattern isNil ifTrue:[ |
|
368 patternField beInvisible. |
|
369 self makeUntabable:patternField. |
|
370 focusSequence := (Array |
|
371 with:enterField |
|
372 with:selectionList |
|
373 with:okButton |
|
374 with:abortButton) |
|
375 ] ifFalse:[ |
|
376 patternField beVisible. |
|
377 self makeTabable:patternField before:enterField. |
|
378 focusSequence := (Array |
|
379 with:patternField |
|
380 with:enterField |
|
381 with:selectionList |
|
382 with:okButton |
|
383 with:abortButton) |
|
384 ]. |
|
385 |
|
386 windowGroup notNil ifTrue:[ |
|
387 windowGroup focusSequence:focusSequence |
|
388 ]. |
|
389 |
|
390 "Modified: 18.10.1997 / 03:02:05 / cg" |
336 ! |
391 ! |
337 |
392 |
338 selectingDirectory:aBoolean |
393 selectingDirectory:aBoolean |
339 "setup the box for directory selection (hides regular files). |
394 "setup the box for directory selection (hides regular files). |
340 Use this, to ask the user for a directories name" |
395 Use this, to ask the user for a directories name" |
374 ] |
429 ] |
375 ! ! |
430 ! ! |
376 |
431 |
377 !FileSelectionBox methodsFor:'initialization'! |
432 !FileSelectionBox methodsFor:'initialization'! |
378 |
433 |
379 ionBox methodsFor:'initialization'! |
434 createEnterField |
380 |
435 "if the (optional) class FilenameEditField is present, use |
381 fied: 18.4.1996 / 20:02:24 / cg" |
436 it, since it provides filename completion. Otherwise, we have |
382 ! |
437 to live with the dumb (default) field ... |
383 |
438 " |
384 ied: 18.10.1997 / 02:47:49 / cg" |
439 FilenameEditField notNil ifTrue:[ |
|
440 ^ FilenameEditField new. |
|
441 ]. |
|
442 ^ super createEnterField |
|
443 |
|
444 "Modified: 18.4.1996 / 20:02:24 / cg" |
|
445 ! |
|
446 |
|
447 initialize |
|
448 |corner| |
|
449 |
|
450 super initialize. |
|
451 selectingDirectory := false. |
|
452 |
|
453 label := resources string:'File dialog'. |
|
454 |
|
455 labelField extent:(0.7 @ labelField height). |
|
456 labelField label:(resources string:'select a file:'). |
|
457 labelField adjust:#left. |
|
458 |
|
459 patternField := EditField in:self. |
|
460 self is3D ifTrue:[ |
|
461 corner := (1.0 @ (labelField origin y+patternField heightIncludingBorder)). |
|
462 ] ifFalse:[ |
|
463 corner := [(width - ViewSpacing - (patternField borderWidth * 2)) @ (labelField origin y+patternField height"IncludingBorder")]. |
|
464 ]. |
|
465 patternField origin:(0.7 @ labelField origin y) corner:corner. |
|
466 patternField rightInset:ViewSpacing. |
|
467 patternField initialText:'*'. |
|
468 patternField leaveAction:[:reason | self patternChanged]. |
|
469 patternField crAction:[self patternChanged]. |
|
470 patternField hiddenOnRealize:true. "delay showing, until a pattern is defined" |
|
471 "/ no, since its invisible |
|
472 "/ self makeTabable:patternField before:enterField. |
|
473 |
|
474 enterField addDependent:self. |
|
475 |
|
476 " |
|
477 FileSelectionBox open |
|
478 FileSelectionBox new show |
|
479 " |
|
480 |
|
481 "Modified: 18.10.1997 / 02:47:49 / cg" |
|
482 ! |
|
483 |
|
484 postRealize |
|
485 "if some default is present in the enterField, |
|
486 scroll to make this one visible" |
|
487 |
|
488 |contents| |
|
489 |
|
490 super postRealize. |
|
491 (contents := enterField contents) notNil ifTrue:[ |
|
492 contents notEmpty ifTrue:[ |
|
493 selectionList makeVisible:contents |
|
494 ] |
|
495 ] |
|
496 |
|
497 "Created: 24.7.1997 / 18:19:14 / cg" |
385 ! ! |
498 ! ! |
386 |
499 |
387 !FileSelectionBox methodsFor:'private'! |
500 !FileSelectionBox methodsFor:'private'! |
388 |
501 |
389 eSelectionBox methodsFor:'private'! ! |
502 updateList |
|
503 selectionList updateList |
|
504 ! ! |
390 |
505 |
391 !FileSelectionBox methodsFor:'queries'! |
506 !FileSelectionBox methodsFor:'queries'! |
392 |
507 |
393 eSelectionBox methodsFor:'queries'! ! |
508 preferredExtent |
|
509 "return my preferred extent - thats the minimum size |
|
510 to make everything visible" |
|
511 |
|
512 |wWanted hWanted mm| |
|
513 |
|
514 "/ If I have an explicit preferredExtent .. |
|
515 |
|
516 preferredExtent notNil ifTrue:[ |
|
517 ^ preferredExtent |
|
518 ]. |
|
519 |
|
520 mm := ViewSpacing. |
|
521 |
|
522 wWanted := mm + |
|
523 labelField preferredExtent x + |
|
524 (mm * 2) + |
|
525 patternField preferredExtent x + |
|
526 mm. |
|
527 (wWanted < width) ifTrue:[ |
|
528 wWanted := width |
|
529 ]. |
|
530 hWanted := mm + labelField height + |
|
531 mm + enterField height + |
|
532 mm + selectionList height + |
|
533 mm + buttonPanel preferredExtent y + |
|
534 mm. |
|
535 |
|
536 (hWanted < height) ifTrue:[ |
|
537 hWanted := height |
|
538 ]. |
|
539 ^ (wWanted @ hWanted) |
|
540 |
|
541 "Modified: 19.7.1996 / 20:44:04 / cg" |
|
542 ! ! |
394 |
543 |
395 !FileSelectionBox methodsFor:'user actions'! |
544 !FileSelectionBox methodsFor:'user actions'! |
396 |
545 |
397 ctionBox methodsFor:'user actions'! |
546 directoryChanged |
398 |
547 selectingDirectory ifTrue:[ |
399 fied: 25.5.1996 / 12:27:05 / cg" |
548 selectionList changeDirectory. |
400 ! |
549 enterField contents:(selectionList directory pathName). |
401 |
550 selectionList setSelection:nil. |
402 ied: / 7.8.1998 / 17:19:26 / cg" |
551 ]. |
|
552 |
|
553 "Created: 18.4.1996 / 18:38:21 / cg" |
|
554 "Modified: 25.5.1996 / 12:27:05 / cg" |
|
555 ! |
|
556 |
|
557 directorySelected |
|
558 "a directory was selected - show the new path in the inputField, |
|
559 if we are in directory mode" |
|
560 |
|
561 selectingDirectory ifTrue:[ |
|
562 |newDir| |
|
563 |
|
564 newDir := (selectionList directory) |
|
565 construct:selectionList selectionValue. |
|
566 enterField contents:newDir pathName. |
|
567 ]. |
|
568 |
|
569 "Created: / 18.4.1996 / 18:46:15 / cg" |
|
570 "Modified: / 7.8.1998 / 17:19:26 / cg" |
|
571 ! |
|
572 |
|
573 doubleClick |
|
574 |entry| |
|
575 |
|
576 entry := selectionList selectionValue. |
|
577 entry notNil ifTrue:[ |
|
578 ((selectionList directory asFilename construct:entry) isDirectory) ifFalse:[ |
|
579 selectingDirectory ifFalse:[ |
|
580 enterField contents:entry. |
|
581 self okPressed |
|
582 ] |
|
583 ] |
|
584 ]. |
|
585 |
|
586 "Modified: 19.10.1997 / 00:17:37 / cg" |
403 ! |
587 ! |
404 |
588 |
405 okPressed |
589 okPressed |
406 "called for both on ok-press and on return-key" |
590 "called for both on ok-press and on return-key" |
407 |
591 |
430 ]. |
614 ]. |
431 ]. |
615 ]. |
432 |
616 |
433 super okPressed |
617 super okPressed |
434 |
618 |
435 <<<<<<< FSelBox.st |
|
436 "Modified: / 9.9.1998 / 21:42:33 / cg" |
|
437 ! |
|
438 |
|
439 ]. |
|
440 ]. |
|
441 |
|
442 super okPressed |
|
443 |
|
444 "Modified: / 9.9.1998 / 21:21:14 / cg" |
619 "Modified: / 9.9.1998 / 21:21:14 / cg" |
445 ======= |
620 ! |
446 "Modified: / 9.9.1998 / 21:21:14 / cg" |
621 |
447 >>>>>>> 1.52 |
622 patternChanged |
448 ! |
623 selectionList pattern:patternField contents. |
449 |
|
450 :patternField contents. |
|
451 self updateList |
624 self updateList |
452 |
625 |
453 "Created: 4.6.1996 / 20:30:23 / cg" |
626 "Created: 4.6.1996 / 20:30:23 / cg" |
|
627 ! |
|
628 |
|
629 selectionChanged |
|
630 |entry| |
|
631 |
|
632 entry := selectionList selectionValue. |
|
633 (selectionList directory asFilename construct:entry) type == #directory ifFalse:[ |
|
634 selectingDirectory ifTrue:[ |
|
635 enterField contents:(selectionList directory pathName). |
|
636 selectionList setSelection:nil. |
|
637 ^ self |
|
638 ] |
|
639 ]. |
|
640 enterField contents:entry |
|
641 |
|
642 "Modified: 21.9.1997 / 12:07:55 / cg" |
454 ! ! |
643 ! ! |
455 |
644 |
456 !FileSelectionBox class methodsFor:'documentation'! |
645 !FileSelectionBox class methodsFor:'documentation'! |
457 |
646 |
458 version |
647 version |
459 ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.53 1998-09-09 20:27:16 cg Exp $' |
648 ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.54 1998-09-09 20:35:43 cg Exp $' |
460 ! ! |
649 ! ! |