ListView.st
changeset 125 3ffa271732f7
parent 121 4e63bbdb266a
child 127 462396b08e30
equal deleted inserted replaced
124:7abd3a234296 125:3ffa271732f7
    36 
    36 
    37 ListView comment:'
    37 ListView comment:'
    38 COPYRIGHT (c) 1989 by Claus Gittinger
    38 COPYRIGHT (c) 1989 by Claus Gittinger
    39 	      All Rights Reserved
    39 	      All Rights Reserved
    40 
    40 
    41 $Header: /cvs/stx/stx/libwidg/ListView.st,v 1.25 1995-05-06 14:17:23 claus Exp $
    41 $Header: /cvs/stx/stx/libwidg/ListView.st,v 1.26 1995-05-09 01:56:08 claus Exp $
    42 '!
    42 '!
    43 
    43 
    44 !ListView class methodsFor:'documentation'!
    44 !ListView class methodsFor:'documentation'!
    45 
    45 
    46 copyright
    46 copyright
    57 "
    57 "
    58 !
    58 !
    59 
    59 
    60 version
    60 version
    61 "
    61 "
    62 $Header: /cvs/stx/stx/libwidg/ListView.st,v 1.25 1995-05-06 14:17:23 claus Exp $
    62 $Header: /cvs/stx/stx/libwidg/ListView.st,v 1.26 1995-05-09 01:56:08 claus Exp $
    63 "
    63 "
    64 !
    64 !
    65 
    65 
    66 documentation
    66 documentation
    67 "
    67 "
   343     list := aCollection.
   343     list := aCollection.
   344 
   344 
   345     list notNil ifTrue:[
   345     list notNil ifTrue:[
   346 	self expandTabs
   346 	self expandTabs
   347     ].
   347     ].
       
   348     widthOfWidestLine := nil.   "/ i.e. unknown
   348     oldFirst := firstLineShown.
   349     oldFirst := firstLineShown.
   349     oldLeft := leftOffset.
   350     oldLeft := leftOffset.
   350     firstLineShown := 1.
   351     firstLineShown := 1.
   351     leftOffset := 0.
   352     leftOffset := 0.
   352     realized ifTrue:[
   353     realized ifTrue:[
   464     "ST-80 compatibility"
   465     "ST-80 compatibility"
   465 
   466 
   466     ^ self on:aModel aspect:aspectSymbol change:nil list:aspectSymbol menu:nil 
   467     ^ self on:aModel aspect:aspectSymbol change:nil list:aspectSymbol menu:nil 
   467 !
   468 !
   468 
   469 
       
   470 on:aModel aspect:aspectSymbol change:changeSymbol 
       
   471     "ST-80 compatibility"
       
   472 
       
   473     ^self on:aModel aspect:aspectSymbol change:changeSymbol list:aspectSymbol menu:nil 
       
   474 !
       
   475 
       
   476 on:aModel aspect:aspectSymbol menu:menuSymbol 
       
   477     "ST-80 compatibility"
       
   478 
       
   479     ^self on:aModel aspect:aspectSymbol change:nil list:aspectSymbol menu:menuSymbol 
       
   480 !
       
   481 
   469 on:aModel aspect:aspectSymbol list:listSymbol menu:menuSymbol 
   482 on:aModel aspect:aspectSymbol list:listSymbol menu:menuSymbol 
   470     "ST-80 compatibility"
   483     "ST-80 compatibility"
   471 
   484 
   472     ^ self on:aModel aspect:aspectSymbol change:nil list:listSymbol menu:menuSymbol 
   485     ^ self on:aModel aspect:aspectSymbol change:nil list:listSymbol menu:menuSymbol 
   473 !
       
   474 
       
   475 on:aModel aspect:aspectSymbol menu:menuSymbol 
       
   476     "ST-80 compatibility"
       
   477 
       
   478     ^self on:aModel aspect:aspectSymbol change:nil list:aspectSymbol menu:menuSymbol 
       
   479 !
       
   480 
       
   481 on:aModel aspect:aspectSymbol change:changeSymbol 
       
   482     "ST-80 compatibility"
       
   483 
       
   484     ^self on:aModel aspect:aspectSymbol change:changeSymbol list:aspectSymbol menu:nil 
       
   485 !
   486 !
   486 
   487 
   487 on:aModel aspect:aspectSymbol change:changeSymbol menu:menuSymbol
   488 on:aModel aspect:aspectSymbol change:changeSymbol menu:menuSymbol
   488     "ST-80 compatibility"
   489     "ST-80 compatibility"
   489 
   490 
   498     changeSymbol notNil ifTrue:[changeMsg := changeSymbol].
   499     changeSymbol notNil ifTrue:[changeMsg := changeSymbol].
   499     menuMsg := menuSymbol.
   500     menuMsg := menuSymbol.
   500     self model:aModel.
   501     self model:aModel.
   501 !
   502 !
   502 
   503 
   503 listMessage:listSymbol 
   504 listMessage 
   504     "ST-80 compatibility: set the listMsg selector; this is sent to
   505     "return the listMsg selector; 
   505      the model (if any) to aquire a new text upon change of the aspect.
   506      if non-nil, this is the message sent to the model (if any) to aquire
       
   507      a new text upon change of the aspect.
   506      This defaults to the aspect-selector."
   508      This defaults to the aspect-selector."
   507 
   509 
   508     listMsg := listSymbol.
   510     ^ listMsg
       
   511 !
       
   512 
       
   513 listMessage:aSymbol 
       
   514     "ST-80 compatibility: set the listMsg selector; 
       
   515      if non-nil, this will be sent to the model (if any) to aquire a 
       
   516      new text upon change of the aspect.
       
   517      This defaults to the aspect-selector."
       
   518 
       
   519     listMsg := aSymbol.
   509 !
   520 !
   510 
   521 
   511 menuHolder
   522 menuHolder
   512     "who has the menu - this defaults to model or nil here,
   523     "who has the menu - this defaults to model or nil here,
   513      but self in textView & friends.
   524      but self in textView & friends.
   539 
   550 
   540 menuPerformer:anObject
   551 menuPerformer:anObject
   541     "change the one that does the menu actions."
   552     "change the one that does the menu actions."
   542 
   553 
   543     menuPerformer := anObject
   554     menuPerformer := anObject
       
   555 !
       
   556 
       
   557 addModelInterfaceTo:aDictionary
       
   558     "see comment in View>>modelInterface"
       
   559 
       
   560     super addModelInterfaceTo:aDictionary.
       
   561     aDictionary at:#listMessage put:listMsg
   544 ! !
   562 ! !
   545 
   563 
   546 !ListView methodsFor:'private'!
   564 !ListView methodsFor:'private'!
   547 
   565 
   548 getListFromModel
   566 getListFromModel
  2612 !
  2630 !
  2613 
  2631 
  2614 keyPress:key x:x y:y
  2632 keyPress:key x:x y:y
  2615     "a key was pressed - handle page-keys here"
  2633     "a key was pressed - handle page-keys here"
  2616 
  2634 
       
  2635     |sensor n|
       
  2636 
  2617     (key == #PreviousPage) ifTrue: [^ self pageUp].
  2637     (key == #PreviousPage) ifTrue: [^ self pageUp].
  2618     (key == #NextPage)     ifTrue: [^ self pageDown].
  2638     (key == #NextPage)     ifTrue: [^ self pageDown].
  2619     (key == #HalfPageUp)   ifTrue: [^ self halfPageUp].
  2639     (key == #HalfPageUp)   ifTrue: [^ self halfPageUp].
  2620     (key == #HalfPageDown) ifTrue: [^ self halfPageDown].
  2640     (key == #HalfPageDown) ifTrue: [^ self halfPageDown].
  2621 
  2641 
  2622     (key == #ScrollUp) ifTrue:[^ self scrollUp].
       
  2623     (key == #ScrollDown) ifTrue:[^ self scrollDown].
       
  2624 
       
  2625     (key == #BeginOfText) ifTrue:[^ self scrollToTop].
  2642     (key == #BeginOfText) ifTrue:[^ self scrollToTop].
  2626     (key == #EndOfText) ifTrue:[^ self scrollToBottom].
  2643     (key == #EndOfText) ifTrue:[^ self scrollToBottom].
  2627 
  2644 
       
  2645     sensor := self sensor.
       
  2646     (key == #ScrollUp) ifTrue:[
       
  2647 	sensor isNil ifTrue:[
       
  2648 	    n := 1
       
  2649 	] ifFalse:[
       
  2650 	    n := 1 + (sensor compressKeyPressEventsWithKey:#ScrollUp).
       
  2651 	].
       
  2652 	^ self scrollUp:n
       
  2653     ].
       
  2654     (key == #ScrollDown) ifTrue:[
       
  2655 	sensor isNil ifTrue:[
       
  2656 	    n := 1
       
  2657 	] ifFalse:[
       
  2658 	    n := 1 + (sensor compressKeyPressEventsWithKey:#ScrollDown).
       
  2659 	].
       
  2660 	^ self scrollDown:n
       
  2661     ].
       
  2662 
  2628     super keyPress:key x:x y:y
  2663     super keyPress:key x:x y:y
  2629 ! !
  2664 ! !