'From Squeak3.1alpha of 28 February 2001 [latest update: #4093] on 29 May 2001 at 11:16:42 pm'! "Change Set: CardPlayerUndone-tk Date: 29 May 2001 Author: Ted Kaehler Update 4093StackSummary-tk.cs added an instance variable to CardPlayer. This was a bad idea. The mechanism that fixes up instances inside an older ImageSegment can't deal with changes in the shape of CardPlayer or Player. In this update we put CardPlayer back the way it was. The results of a template search in a StackMorph are now held in a class variable of each specfic CardPlayer class."! Player subclass: #CardPlayer instanceVariableNames: 'privateMorphs properties ' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Stacks'! !CardPlayer commentStamp: 'tk 5/29/2001 23:13' prior: 0! CardPlayer Instance variables of the Uniclass represent the data in the "fields" of each card in the stack. Each Instance variable is some kind of value holder. The code for the *buttons* on the background resides in the CardPlayer uniclass. privateMorphs -- OrderedCollection of objects specific to this card. Individual CardPlayer classes need to store the search results of any instances that are templates. As a hack, we use a class variable TemplateMatches in each individual class (CardPlayer21). It is initialized in #matchIndex:. TemplateMatches an IndentityDictionary of (aCardPlayer -> (list of matching cards, index in that list)) ! !CardPlayer methodsFor: 'as template' stamp: 'tk 5/29/2001 22:44'! matchIndex | tms | "Index of one we are looking at, in the cards that matched the last search with this template." tms _ self class classPool at: #TemplateMatches ifAbsent: [^ 0]. ^ (tms at: self ifAbsent: [#(0 0)]) second. ! ! !CardPlayer methodsFor: 'as template' stamp: 'tk 5/29/2001 22:47'! matchIndex: newPlace | tms pair | "One we are looking at, in cards that matched the last template search." tms _ self class classPool at: #TemplateMatches ifAbsent: [ self class addClassVarName: 'TemplateMatches'. self class classPool at: #TemplateMatches put: IdentityDictionary new]. pair _ tms at: self ifAbsent: [tms at: self put: (Array new: 2)]. pair at: 2 put: newPlace. newPlace = 0 ifTrue: [^ self]. pair first ifNil: [^ self]. (costume valueOfProperty: #myStack ifAbsent: [^ self]) goToCard: ((pair first "list") at: newPlace). self changed: #matchIndex. "update my selection" ! ! !CardPlayer methodsFor: 'as template' stamp: 'tk 5/29/2001 23:07'! matchNames | list str ll tms | "List of names of cards that matched the last template search." tms _ self class classPool at: #TemplateMatches ifAbsent: [^ #()]. list _ (tms at: self ifAbsent: [#(#() 0)]) first. ^ list collect: [:cd | str _ ''. (ll _ cd allStringsAfter: nil) ifNotNil: [ str _ ll inject: '' into: [:strr :this | strr, this]]. (str copyFrom: 1 to: (30 min: str size)), ' (' , cd hash printString, ')']. "Maybe include a card title?"! ! !CardPlayer methodsFor: 'as template' stamp: 'tk 5/29/2001 22:49'! results "Return my (cardlist index) pair from the last search" ^ (self class classPool at: #TemplateMatches ifAbsent: [^ Array new: 2]) at: self ! ! !StackMorph methodsFor: 'menu' stamp: 'tk 5/29/2001 23:00'! findViaTemplate | list pl cardInst | "Current card is the template. Only search cards in this background. Look at cards directly (not allText). Key must be found in the same field as in the template. HyperCard style (multiple starts of words). Put results in a list, outside the stack." list _ self templateMatches. "put up a PluggableListMorph" cardInst _ self currentCard. cardInst matchIndex: 0. "establish entries" cardInst results at: 1 put: list. self currentPage setProperty: #myStack toValue: self. "way to get back" pl _ PluggableListMorph new on: cardInst list: #matchNames selected: #matchIndex changeSelected: #matchIndex: menu: nil "#matchMenu:shifted:" keystroke: nil. pl color: (Color blue mixed: 0.17 with: Color white). pl toggleCornerRounding; width: 232; retractableOrNot. ActiveHand attachMorph: pl. ! ! CardPlayer removeSelector: #properties! Player subclass: #CardPlayer instanceVariableNames: 'privateMorphs ' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Stacks'!