-
Notifications
You must be signed in to change notification settings - Fork 0
/
PickACard.pck.st
113 lines (92 loc) · 3.45 KB
/
PickACard.pck.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
'From Cuis 5.0 [latest update: #4878] on 22 September 2021 at 12:35:54 pm'!
'Description Select from a Pallet of Playing Cards.'!
!provides: 'PickACard' 1 2!
!requires: 'Morphic-Games-Solitaire' 1 114 nil!
!requires: 'Morphic-Misc1' 1 187 nil!
SystemOrganization addCategory: 'PickACard'!
!classDefinition: #PickableCardMorph category: 'PickACard'!
CardMorph subclass: #PickableCardMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'PickACard'!
!classDefinition: 'PickableCardMorph class' category: 'PickACard'!
PickableCardMorph class
instanceVariableNames: ''!
!classDefinition: #PickACardImage category: 'PickACard'!
ImagePickerPanel subclass: #PickACardImage
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'PickACard'!
!classDefinition: 'PickACardImage class' category: 'PickACard'!
PickACardImage class
instanceVariableNames: ''!
!PickACardImage commentStamp: '<historical>' prior: 0!
I am just a way of getting an initializedInstance from the New Morph.. menu..
See my class side.
| pickerMorph savedExtent |
pickerMorph := self pickACard.
savedExtent := pickerMorph morphExtent.
pickerMorph openInWorld. "openInWorld changes extent"
pickerMorph morphExtent: savedExtent.!
!PickACardImage class methodsFor: 'instance creation' stamp: 'KenD 9/22/2021 12:34:50'!
initializedInstance
"Answer a card picker pallet"
^self pickACard.
! !
!PickableCardMorph methodsFor: 'dropping/grabbing' stamp: 'KenD 9/18/2021 13:37:05'!
aboutToBeGrabbedBy: aHand
"I'm about to be grabbed by the hand."
^ self ! !
!PickableCardMorph methodsFor: 'dropping/grabbing' stamp: 'KenD 9/18/2021 12:45:47'!
allowsMorphDrop
"Answer whether we accept dropping morphs. By default answer false."
^ false! !
!PickableCardMorph methodsFor: 'dropping/grabbing' stamp: 'KenD 9/18/2021 12:46:25'!
allowsSubmorphDrag
"Answer whether our morphs can just be grabbed with the hand, instead of requiring the use of the halo. By default answer false."
^ true! !
!PickableCardMorph methodsFor: 'dropping/grabbing' stamp: 'KenD 9/18/2021 13:52:07'!
click: evt localPosition: localEventPosition
"Ignored"
^false! !
!PickableCardMorph methodsFor: 'dropping/grabbing' stamp: 'KenD 9/18/2021 13:59:30'!
processMouseDown: evt localPosition: localEventPosition
"Override the CardMorph override"
(evt mouseButton1Pressed) ifTrue: [
evt hand grabMorph: self. "Pick me up"
evt wasHandled: true
]
ifFalse: [
evt hand
waitForClicksOrDrag: self
event: evt
dragSel: #click:localPosition:
clkSel: #click:localPosition:
]
! !
!PickableCardMorph methodsFor: 'dropping/grabbing' stamp: 'KenD 9/18/2021 13:32:40'!
wantsToBeDroppedInto: someMorph
^ true! !
!PickACardImage class methodsFor: 'instance creation' stamp: 'KenD 9/18/2021 12:47:10'!
pickACard
"Answer a pallet of CardMorph selections"
| nameImageCollection |
nameImageCollection := OrderedCollection new: 52.
#(Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King)
do: [ :face |
#(Clubs Diamonds Hearts Spades) do: [ :value |
nameImageCollection addLast:
( (face, '+', value)
->
(PickableCardMorph the: face of: value) ).
] ].
^ self
privateBuildPanelLabel: 'Pick a Card'
collection: nameImageCollection
transducer: [:card | card ] ! !
!PickACardImage class methodsFor: 'new-morph participation' stamp: 'KenD 9/18/2021 12:28:03'!
includeInNewMorphMenu
"Return true for all classes that can be instantiated from the menu"
^ true! !