'From Squeak3.8gamma of ''24 November 2004'' [latest update: #6662] on 18 May 2005 at 12:21:52 am'!
CWidgetTest subclass: #CBookTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Tweak-Books'!
!CBookTest commentStamp: 'tak 5/15/2005 16:33' prior: 0!
CBookTest buildSuite run!
CList subclass: #CBook
instanceVariableNames: '
view
selectionName
'
classVariableNames: ''
poolDictionaries: ''
category: 'Tweak-Books'!
CPlayer subclass: #CBookCostume
instanceVariableNames: '
playerItems
selectedPlayer
'
classVariableNames: ''
poolDictionaries: ''
category: 'Tweak-Books'!
CSymbolType subclass: #CBookViewType
instanceVariableNames: '
'
classVariableNames: ''
poolDictionaries: ''
category: 'Tweak-Books'!
CPlayer subclass: #CBookWindow
instanceVariableNames: '
list
control
book
view
nameField
'
classVariableNames: ''
poolDictionaries: ''
category: 'Tweak-Books'!
!CBookTest methodsFor: 'testing' stamp: 'tak 5/16/2005 11:41'!
testAdd
"self debug: #testAdd"
| window |
window _ CBookWindow new.
window open.
window add.
self waitTick.
self assert: window player items cursor = 1.
self assert: window player items size = 1.
self assert: window book elements size = 1.
self assert: window book elements first class = CPlayer.
window close.
! !
!CBookTest methodsFor: 'testing' stamp: 'tak 5/15/2005 22:56'!
testBuildPanel
"self debug: #testBuildPanel"
| panel |
panel _ CBookWindow new.
panel open.
self assert: panel player = panel book player.
self assert: panel player items = panel list items.
panel close! !
!CBookTest methodsFor: 'testing' stamp: 'tak 5/16/2005 17:37'!
testCleanupWhenCostumeChange
"self debug: #testCleanupWhenCostumeChange"
| book bookCostume |
book _ CBook open.
book open.
CViewerFlap openForTarget: book inWorld: book.
book view: #small.
bookCostume _ book costume.
book view: #window.
self assert: bookCostume container isNil.
book close.! !
!CBookTest methodsFor: 'testing' stamp: 'tak 5/15/2005 09:06'!
testCostume
"self debug: #testCostume"
| book |
book _ CBook new.
self assert: book costume class = CBookCostume
! !
!CBookTest methodsFor: 'testing' stamp: 'tak 5/16/2005 18:25'!
testDrop
"self debug: #testDrop"
| book bookPane rect |
book _ CBook newWindow.
book costume setupCostume.
bookPane _ book costume book.
book add.
bookPane onDrop: (rect _ CRectanglePlayer new).
self waitTick.
self assert: rect container name = 'page'.
"Reject myself"
bookPane onDrop: book.
self waitTick.
self assert: (book container name = 'page') not.! !
!CBookTest methodsFor: 'testing' stamp: 'tak 5/15/2005 17:01'!
testFirstPage
"self debug: #testFirstPage"
| book element1 element2 |
book _ CBook new.
element1 _ CRectanglePlayer new.
element1 name: 'first'.
element2 _ CEllipsePlayer new.
element2 name: 'second'.
book add: element1.
book add: element2.
self waitTick.
book cursor: 2.
self waitTick.
self assert: book items size = 2.
self assert: book elements size = 1.
self assert: book elements first = element2.
! !
!CBookTest methodsFor: 'testing' stamp: 'tak 5/16/2005 17:23'!
testFollowPlayerAfterCostumeChanged
"self debug: #testFollowPlayerAfterCostumeChanged"
| book oldCostume |
book _ CBook newWindow.
book add: CEllipsePlayer new.
book add: CRectanglePlayer new.
book open.
book view: #small.
oldCostume _ book costume.
book view: #window.
self assert: oldCostume player = nil. ! !
!CBookTest methodsFor: 'testing' stamp: 'tak 5/15/2005 22:56'!
testView
"self debug: #testView"
| book |
book _ CBook new.
self assert: book view = #small.
book view: #window.
self assert: book view = #window.
self assert: book costume class = CBookWindow.
book view: #small.
self assert: book view = #small.
book costume class = CBookCostume.
! !
!CPlayer methodsFor: 'graphic' stamp: 'tak 5/17/2005 11:16'!
thumbnail
^ self makeIcon! !
!CBook methodsFor: 'actions' stamp: 'tak 5/16/2005 11:42'!
add
| newPage |
newPage _ self class buildNewPage.
self add: newPage.
self selection: newPage! !
!CBook methodsFor: 'actions' stamp: 'tak 5/15/2005 00:50'!
remove
self removeAt: self cursor! !
!CBook methodsFor: 'initialize' stamp: 'tak 5/15/2005 00:40'!
defaultCostume
^ CBookCostume! !
!CBook methodsFor: 'accessing' stamp: 'tak 5/15/2005 23:41'!
selectionName
^ self selection
ifNotNil: [self selection name]! !
!CBook methodsFor: 'accessing' stamp: 'tak 5/15/2005 23:41'!
selectionName: aValue
self selection
ifNotNil: [self selection name: aValue].
^ aValue! !
!CBook methodsFor: 'accessing' stamp: 'tak 5/15/2005 14:57'!
view
^ costume view! !
!CBook methodsFor: 'accessing' stamp: 'tak 5/16/2005 12:37'!
view: aSymbol
aSymbol = self view
ifTrue: [self].
aSymbol = #small
ifTrue: [^ self openSmallCostume].
aSymbol = #window
ifTrue: [self openWindowCostume].
aSymbol = #full
ifTrue: [self openFullCostume].
^ costume view: aSymbol! !
!CBook methodsFor: 'events' stamp: 'tak 5/16/2005 00:24'!
onCursorChanged: newCursor
super onCursorChanged: newCursor.
self signal: #selectionNameChanged! !
!CBook methodsFor: 'costume' stamp: 'tak 5/16/2005 17:24'!
openFullCostume
| oldCostume newCostume base pos box |
oldCostume _ self costume.
newCostume _ CBookWindow new.
newCostume setupFullCostume.
self costume: newCostume.
oldCostume container
ifNotNil: [self open.
base _ oldCostume world project.
self world project addFirst: newCostume book.
newCostume book bounds: base standardBounds].
pos _ CWindowManager default altCollapsePositionFor: self.
box _ pos x @ (pos y - self asPrimCostume minExtent y) extent: self asPrimCostume minExtent.
self bounds: box.
newCostume costume costume animateBoundsFrom: oldCostume bounds to: box.
oldCostume close.
oldCostume player: nil.
self waitTick! !
!CBook methodsFor: 'costume' stamp: 'tak 5/16/2005 17:24'!
openSmallCostume
| oldCostume newCostume |
oldCostume _ self costume.
newCostume _ CBookCostume new.
newCostume stopScript: #onMouseDown.
newCostume layout: CTableLayout new.
newCostume layout hResizing: #shrinkWrap.
newCostume layout vResizing: #shrinkWrap.
self costume: newCostume.
oldCostume container
ifNotNil: [self open.
newCostume globalPosition: oldCostume book globalPosition.
oldCostume costume costume animateBoundsFrom: oldCostume bounds to: newCostume bounds].
oldCostume close.
oldCostume player: nil.
self waitTick! !
!CBook methodsFor: 'costume' stamp: 'tak 5/16/2005 17:24'!
openWindowCostume
| oldCostume newCostume |
oldCostume _ self costume.
newCostume _ CBookWindow new.
self costume: newCostume.
oldCostume container
ifNotNil: [self open.
newCostume globalPosition: oldCostume book globalPosition.
newCostume costume costume animateBoundsFrom: oldCostume bounds to: newCostume bounds].
oldCostume close.
oldCostume player: nil.
self waitTick! !
!CBook methodsFor: 'tiles' stamp: 'tak 5/16/2005 23:56'!
viewerSpecAdditions
^ '
'! !
!CBook methodsFor: 'scripting' stamp: 'tak 5/18/2005 00:21'!
scriptsWithClassDo: aBlock
super scriptsWithClassDo: aBlock.
" #(#next prev )
do: [:each | aBlock value: each value: CHolder]
"! !
!CBook class methodsFor: 'instance creation' stamp: 'tak 5/16/2005 18:27'!
buildNewPage
| page |
page _ CPlayer new.
page hResizing: #spaceFill;
vResizing: #spaceFill.
page name: 'page'.
" page color: Color blue lighter lighter."
^ page! !
!CBook class methodsFor: 'instance creation' stamp: 'tak 5/16/2005 16:42'!
newWindow
| book |
book _ self new.
book costume: CBookWindow.
^ book! !
!CBook class methodsFor: 'instance creation' stamp: 'tak 5/16/2005 16:43'!
open
| book |
book _ self newWindow.
book add: self startPage.
book cursor: 1.
^ book open! !
!CBook class methodsFor: 'constants' stamp: 'tak 5/15/2005 18:54'!
startPage
| page item |
page _ self buildNewPage.
item _ CPlayer new.
item position: 100@50.
item graphic: (Form fromBinaryStream: 'iVBORw0KGgoAAAANSUhEUgAAAGQAAAB2CAYAAAA+/DbEAAAS4ElEQVR4nO2db0wUaZ7Hv9Wg
DpxWO+I6GruU3RNNgIvNZDayrXsyqyHixhmOZW1fXBTYwCTKTrN3PZfxThkH1zjJdHK0y0wy
bQbadV/QG5awTgaMwR1GpY+JmxEnQCL4orExOrMyY7cODApd96K6ivrbVdXdQDf0J6lQf7qe
Kupbz/N7nt/ze54ikEI3178+tz2NTisKGejHu9bVXohn2oTK8SMAGsNLD4Ai0fHVAMwy++NB
T5zS6QfwOB4Jbd1OZf/LKz8pMr74T9lPA5Po9PThP84e9O07uKPC8qOjn8fjGpEE2QzAF4+L
LHZ6H34AAB0rlqdXvLLmjUAsaRkiHGuMJeElSOk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b
Z2wXJTUqvWLE85ksaUE6PX0SMVaSGfiN/ZeqU7/ypxXX+0zEg3T46BZE6TNzeohHtXhkYCzm
8eFyA/6fBidxvFK+UajEl95hRbuakydj8EWDdPjoFuS3ZU69pyx6mh2deLl9VhB+sNxKo74q
cSrIIQ6IewnVirCZ0LRikaVVkGyxQy0FQ4ElR3Y++Ej8/KU3FT/Cq7XIGj3hPNyx31oY00wP
i41VZGY0jUJfpIOabQhtoDtetmxNCRIrROTQXM02ZNe62guI0em4VJCtWbHQdMTuDV1GPUTM
pHKIBiLVrFYsX9YT6Vxd1d6fv/Tm7RvfNFUQIcLN7nvgH8cZ28WkdrnPGwROKXVMseiu9u5a
V3uBNtAVrAu509OXEkMDNOjHK5alq05SHVU7ZNe62gs0ESoC0J/MfR/zCUEQjWq5A4jB2xuu
Sxf86fP/OVJ35tengt99nx1tWgDzHad4fTpooXkSmMDdwfvcNg26Z9dLte9qOTduEVU3vmk6
QoQIdnryJc+1rtsYGRzD3tJX+rfmbizSkjuAOArCp/e7ps3EFFFKM5GPcfk+YpLSsWJ5eoVW
MYA5EoTPUhSHBv3YAOKUZf0x3Z7YeQ0C7f2uaTMxbcgOzYRKCRCliOHjxwkLATeW06fYz0/o
P32B6X3Y9DoIwgwaZiSv/fGFhXBHKwTLggsihs1FdIguApBN03Q2AaJogW+LDd3hOpYIguih
CdpH06H+SN5bvSScIEr8/duPjM9mZsyYoc00gdUIiwUABIhsxF78+djZeQgQj0GgHzTdT6QZ
HosnGUuxhPh/K7pFt9E2vvIAAAAASUVORK5CYII=' base64Decoded asByteArray readStream).
item extent: item graphic extent.
page add: item.
^ page! !
!CBookCostume methodsFor: 'initialize' stamp: 'tak 5/15/2005 00:38'!
defaultPlayer
^CBook! !
!CBookCostume methodsFor: 'events' stamp: 'tak 5/16/2005 17:30'!
onCursorChanged
self removeAll.
(player notNil and: [player selection notNil])
ifTrue: [self add: player selection].! !
!CBookCostume methodsFor: 'events' stamp: 'tak 5/16/2005 18:25'!
onDrop: aPlayer
| selection aCostume tfm |
aPlayer = self ifTrue: [^aPlayer signal: #dropReject].
(self isIn: aPlayer) ifTrue: [^aPlayer signal: #dropReject].
selection _ self player selection.
selection ifNil: [^aPlayer signal: #dropReject].
aCostume := aPlayer asPrimCostume.
"Get player in child frame"
tfm := selection globalToLocal composedWithLocal: aCostume localToGlobal.
aCostume transform: tfm.
selection add: aPlayer.
"And inform it about the drop"
aPlayer signal: #dropAccept with: selection.
! !
!CBookCostume methodsFor: 'events' stamp: 'tak 5/16/2005 17:26'!
onItemsChangedInPlayer
"There should be no need for subclasses to override this method;
It merely ensures that changes in the player are propagated accordingly."
playerItems := player
ifNil: [nil]
ifNotNil: [player items]! !
!CBookCostume methodsFor: 'events' stamp: 'tak 5/15/2005 18:46'!
onMouseDown
| draggee |
self player selection ifNil: [^self].
self player view = #small ifTrue: [^self].
draggee _ self player selection costume dragChildAt: self cursorPoint.
draggee notNil
ifTrue: [^ draggee onDrag].
! !
!CBookCostume methodsFor: 'events' stamp: 'tak 5/15/2005 16:45'!
onPlayerChanged
"My player has changed, update the items"
super onPlayerChanged.
self onItemsChangedInPlayer.
self onCursorChanged.! !
!CBookCostume methodsFor: 'accessing' stamp: 'tak 5/16/2005 16:09'!
book
^ self! !
!CBookCostume methodsFor: 'accessing' stamp: 'tak 5/15/2005 00:53'!
playerItems
"Answer the playerItems of the receiver"
^self propertyValueAt: #playerItems! !
!CBookCostume methodsFor: 'accessing' stamp: 'tak 5/15/2005 00:53'!
playerItems: aValue
"Modify the receiver's playerItems"
^self propertyValueAt: #playerItems put: aValue with: #playerItemsChanged! !
!CBookCostume methodsFor: 'accessing' stamp: 'tak 5/15/2005 09:08'!
selectedPlayer
"Answer the selectedPlayer of the receiver"
^self propertyValueAt: #selectedPlayer! !
!CBookCostume methodsFor: 'accessing' stamp: 'tak 5/15/2005 09:08'!
selectedPlayer: aValue
"Modify the receiver's selectedPlayer"
^self propertyValueAt: #selectedPlayer put: aValue with: #selectedPlayerChanged! !
!CBookCostume methodsFor: 'accessing' stamp: 'tak 5/15/2005 14:59'!
view
^ #small! !
!CBookCostume methodsFor: 'accessing' stamp: 'tak 5/16/2005 11:53'!
view: aSymbol
^ #small! !
!CBookViewType class methodsFor: 'accessing' stamp: 'tak 5/15/2005 16:55'!
enumValues
^#(small window full)! !
!CBookWindow methodsFor: 'actions' stamp: 'tak 5/15/2005 14:24'!
add
player add.! !
!CBookWindow methodsFor: 'actions' stamp: 'tak 5/16/2005 01:03'!
close
super close.
book close! !
!CBookWindow methodsFor: 'actions' stamp: 'tak 5/15/2005 14:14'!
next
player next.! !
!CBookWindow methodsFor: 'actions' stamp: 'tak 5/15/2005 12:06'!
prev
player prev.! !
!CBookWindow methodsFor: 'actions' stamp: 'tak 5/15/2005 14:24'!
remove
player remove! !
!CBookWindow methodsFor: 'events' stamp: 'tak 5/17/2005 10:26'!
onCursorChanged
player selection signal: #thumbnailChanged! !
!CBookWindow methodsFor: 'events' stamp: 'tak 5/15/2005 15:24'!
onPlayerChanged
super onPlayerChanged.
self updateAll! !
!CBookWindow methodsFor: 'events' stamp: 'tak 5/16/2005 17:32'!
updateAll
book player: player.
player
ifNil: [list items: CCollection new.
nameField player: nil]
ifNotNil: [list items: player items.
list wrapCursor: true.
nameField
player: (player fieldNamed: #selectionName)]! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/16/2005 13:53'!
buttonSpec
"#(label selector)"
^ #(
('-' remove)
('L' prev)
('R' next)
('+' add)
)
! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/15/2005 23:01'!
defaultCostume
^ CWindow! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/15/2005 23:01'!
defaultPlayer
^ CBook! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/16/2005 00:06'!
initialize
super initialize.
self define: #list as: CList new.
self define: #control as: CPlayer new.
self define: #book as: CBookCostume new.
self define: #nameField as: CInputField new.
self updateAll.
! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/15/2005 23:12'!
setupBookCostume
| aFrame |
book hResizing: #spaceFill; vResizing: #spaceFill.
book hScrollable: false; vScrollable: nil.
book color: Color transparent.
book layout: CTableLayout new.
book layoutFrame: (aFrame _ CLayoutFrame new).
aFrame leftOffset: 0; leftFraction: 100/400.
aFrame topOffset: 25; topFraction: 0.0.
aFrame rightOffset: 0; rightFraction: 1.0.
aFrame bottomOffset: 0; bottomFraction: 1.0.
! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/16/2005 13:50'!
setupControlCostume
| aFrame button |
control removeAll.
self buttonSpec do: [ :spec |
button _ CButton new.
self startScript: spec second when: {button. #fire}.
button fillStyle: #none.
button label: spec first.
button font: (TextStyle named: #WindowFont) defaultFont.
button extent: 20@20.
control add: button].
nameField borderStyle: #simple.
nameField extent: 60 @ 20.
control add: nameField.
control fillStyle: #verticalGradient.
control fillColors: CWidgetLibrary default menuColors.
control borderStyle: #none.
control extent: 160@25.
control layout: CTableLayout new.
control layout listDirection: #leftToRight.
control hResizing: #spaceFill; vResizing: #spaceFill.
control layout listCentering: #center.
control layout cellInset: 4.
control layoutInset: 2.
control layoutFrame: (aFrame _ CLayoutFrame new).
aFrame leftOffset: 0; leftFraction: 0.0.
aFrame topOffset: 0; topFraction: 0.0.
aFrame rightOffset: 0; rightFraction: 1.0.
aFrame bottomOffset: 25; bottomFraction: 0.
! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/15/2005 23:07'!
setupCostume
self removeAll.
super setupCostume.
costume extent: 400@300.
costume layout _ CProportionalLayout new.
" costume layout hResizing: #rigid.
costume layout vResizing: #rigid."
costume label: 'Book'.
self setupListCostume.
self add: list.
self setupBookCostume.
self add: book.
costume decorate: costume elements color: CWidgetLibrary default windowColor.
self setupControlCostume.
self add: control.
! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/17/2005 10:37'!
setupFullCostume
self removeAll.
self setupControlCostume.
self add: control.
self layout: CTableLayout new.
self layout hResizing: #shrinkWrap.
self layout vResizing: #shrinkWrap.
self control hResizing: #shrinkWrap.
self control vResizing: #shrinkWrap.
self width: 200.
self! !
!CBookWindow methodsFor: 'initialize' stamp: 'tak 5/17/2005 10:01'!
setupListCostume
| aFrame |
list hResizing: #spaceFill; vResizing: #spaceFill.
list width: 120.
list allowDeselect: false.
list layoutFrame: (aFrame _ CLayoutFrame new).
list itemMaker: CProjectCostume.
aFrame leftOffset: 0; leftFraction: 0.0.
aFrame topOffset: 25; topFraction: 0.0.
aFrame rightOffset: 0; rightFraction: 100 / 400.
aFrame bottomOffset: 0; bottomFraction: 1.0.
! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 12:03'!
book
"Answer the book of the receiver"
^self propertyValueAt: #book! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 12:03'!
book: aValue
"Modify the receiver's book"
^self propertyValueAt: #book put: aValue with: #bookChanged! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 10:10'!
control
"Answer the control of the receiver"
^self propertyValueAt: #control! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 10:10'!
control: aValue
"Modify the receiver's control"
^self propertyValueAt: #control put: aValue with: #controlChanged! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 10:10'!
list
"Answer the list of the receiver"
^self propertyValueAt: #list! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 10:10'!
list: aValue
"Modify the receiver's list"
^self propertyValueAt: #list put: aValue with: #listChanged! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 23:35'!
nameField
"Answer the nameField of the receiver"
^self propertyValueAt: #nameField! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 23:35'!
nameField: aValue
"Modify the receiver's nameField"
^self propertyValueAt: #nameField put: aValue with: #nameFieldChanged! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 19:43'!
view
"Answer the view of the receiver"
^self propertyValueAt: #view ifAbsentPut: #window! !
!CBookWindow methodsFor: 'accessing' stamp: 'tak 5/15/2005 19:40'!
view: aValue
"Modify the receiver's view"
^self propertyValueAt: #view put: aValue with: #viewChanged! !
!CBookWindow class methodsFor: 'class initialization' stamp: 'tak 5/15/2005 17:56'!
initialize
Smalltalk
at: #CProjectBuilder
ifPresent: [:pb | pb registerOpenCommand: {'Book'. {CBook. #open}. 'Muti-page structures'}]! !
CBookWindow initialize!
!CBook reorganize!
('actions' add remove)
('initialize' defaultCostume)
('accessing' selectionName selectionName: view view:)
('events' onCursorChanged:)
('costume' openFullCostume openSmallCostume openWindowCostume)
('tiles' viewerSpecAdditions)
('scripting' scriptsWithClassDo:)
!