'From etoys2.1 of 26 July 2007 [latest update: #1556] on 16 August 2007 at 11:36:46 pm'! "Change Set: bookControls-sw Date: 17 August 2007 Author: Scott Wallace TRAC 2820: Add an option allowing book controls to appear at top *or* bottom of the book; the option is governed by a new item in the main book menu at the center of its own control panel. Make items governing location, shortness, and visibility of the book controls available both in the book's viewer and in the toggle section of the main book menu."! !BooklikeMorph methodsFor: 'misc' stamp: 'sw 8/15/2007 19:23'! pageControlsAtTopString "Answer a string characterizing whether page controls are currently shown at the top of the book." ^ (self pageControlsAtTop ifTrue: [''] ifFalse: ['']), 'page controls at top' translated! ! !BooklikeMorph methodsFor: 'misc' stamp: 'sw 8/15/2007 20:10'! pageControlsShortString "Answer a string characterizing whether page controls are currently to be shown in their short form." ^ (self pageControlsShort ifTrue: [''] ifFalse: ['']), 'page controls short' translated! ! !BooklikeMorph methodsFor: 'misc' stamp: 'sw 8/15/2007 20:17'! showingPageControlsString "Answer a string characterizing whether page controls are currently showing." ^ (self pageControlsVisible ifTrue: [''] ifFalse: ['']), 'page controls visible' translated! ! !BooklikeMorph methodsFor: 'page controls' stamp: 'sw 8/15/2007 20:35'! fewerPageControls "The black caret at left of the page-controls was hit at a time when the book was showing its full form of page controls." self currentEvent shiftPressed ifTrue: [self hidePageControls] ifFalse: [self pageControlsShort: true]! ! !BooklikeMorph methodsFor: 'page controls' stamp: 'sw 8/15/2007 19:31'! indexForPageControls "Answer which submorph should hold the page controls" ^ self pageControlsAtTop ifTrue: [1] ifFalse: [submorphs size + 1]! ! !BooklikeMorph methodsFor: 'page controls' stamp: 'sw 8/15/2007 20:17'! showPageControls "Make the page controls visible." self showPageControls: (self pageControlsShort ifTrue: [self shortControlSpecs] ifFalse: [self fullControlSpecs])! ! !BookMorph methodsFor: 'menu' stamp: 'sw 8/15/2007 20:11'! addBookToggleItemsTo: aMenu "Add the standard book-related toggle items to a menu." #( (keepingUniformPageSizeString toggleMaintainUniformPageSize 'If set, when you resize the book, all of its pages get automatically resized.') (pageControlsAtTopString togglePageControlsAtTop 'If on, page controls (when present), will appear at the the top of the book; if off, they will appear at its bottom') (pageControlsShortString togglePageControlsShort 'If set, the shorter form of page controls will be used when page controls are showing') (showingPageControlsString toggleShowingOfPageControls 'If set, a row of page controls will appear at the top of the book') (usingPrivatePresenterString toggleUsingPrivatePresenter 'If set, stop-step-go buttons within the page''s interior will govern only scripts for objects residing within the page') (showingFullScreenString toggleFullScreen 'If set, the book page occupies the entire screen') (wrappingAtEndString toggleWrapPages 'If set, the first page in the book will be considered to be the next page after the last page, so that continuallly pressing the next or previous buttons will continually cycle through all pages of the book') ) do: [:tuple | aMenu addUpdating: tuple first target: self action: tuple second. tuple size > 2 ifTrue: [aMenu balloonTextForLastItem: tuple third translated]]! ! !BookMorph methodsFor: 'menu' stamp: 'sw 8/15/2007 20:31'! invokeShortBookMenu "Invoke the shorter version of the book's control panel menu." | aMenu | self class == BookMorph ifFalse: [^ self invokeBookMenu]. aMenu _ MenuMorph new defaultTarget: self. aMenu addTitle: 'Book' translated. aMenu addStayUpItem. aMenu addTranslatedList: #( ('find...' textSearch) ('go to page...' goToPage) - ('show more controls' showMoreControls) - ('revert this page' revertPage) ('revert entire book' revertAllPages)). aMenu popUpInWorld ! ! !BookMorph methodsFor: 'navigation' stamp: 'sw 8/15/2007 19:38'! insertPageMorphInCorrectSpot: aPageMorph "The user is going to a new page; the old one is gone; add the new one at the appropriate place." self pageControlsAtTop ifTrue: [self addMorphBack: (currentPage _ aPageMorph)] ifFalse: [self addMorphFront: (currentPage _ aPageMorph)] ! ! !BookMorph methodsFor: 'navigation' stamp: 'sw 8/15/2007 20:01'! showMoreControls "Show more page controls -- or, if shift-key pressed, hide page controls." self hidePageControls. self currentEvent shiftPressed ifFalse: [self pageControlsShort: false. self showPageControls]! ! !BookMorph methodsFor: 'uniform page size' stamp: 'sw 8/15/2007 19:26'! pageControlsAtTop "Answer whether I am currently set up to have my page-controls appear at top" ^ self valueOfProperty: #pageControlsAtTop ifAbsentPut: [true]! ! !BookMorph methodsFor: 'uniform page size' stamp: 'sw 8/15/2007 19:32'! pageControlsAtTop: aBoolean "Set the property governing whether page controls will appear at top" self setProperty: #pageControlsAtTop toValue: aBoolean. self pageControlsVisible ifTrue: [self hidePageControls. self showPageControls]! ! !BookMorph methodsFor: 'uniform page size' stamp: 'sw 8/15/2007 19:58'! pageControlsShort "Answer whether I am currently set up to have my page-controls be in the short form" ^ self valueOfProperty: #pageControlsShort ifAbsentPut: [true]! ! !BookMorph methodsFor: 'uniform page size' stamp: 'sw 8/15/2007 20:06'! pageControlsShort: aBoolean "Set the property governing whether page controls will appear in their short form" self setProperty: #pageControlsShort toValue: aBoolean. self pageControlsVisible ifTrue: [self hidePageControls. self showPageControls] ifFalse: [self hidePageControls]! ! !BookMorph methodsFor: 'uniform page size' stamp: 'sw 8/15/2007 19:27'! togglePageControlsAtTop "Toggle whether or not the receiver's page controls should appear at top" self pageControlsAtTop: self pageControlsAtTop not! ! !BookMorph methodsFor: 'uniform page size' stamp: 'sw 8/15/2007 19:55'! togglePageControlsShort "Toggle whether or not the receiver's page controls should be in the short form" self pageControlsShort: self pageControlsShort not! ! !BookMorph class methodsFor: 'scripting' stamp: 'sw 8/15/2007 20:19'! additionsToViewerCategories "Answer a list of ( ) pairs that characterize the phrases this kind of morph wishes to add to various Viewer categories." ^ #((#'book navigation' ((command goto: 'go to the given page' Player) (command nextPage 'go to next page') (command previousPage 'go to previous page') (command firstPage 'go to first page') (command lastPage 'go to last page') (slot pageNumber 'The ordinal number of the current page' Number readWrite Player getPageNumber Player setPageNumber:) (slot numberOfPages 'How many pages here are in the book' Number readOnly Player getNumberOfPages Player unused) (slot pageControlsShowing 'Whether page controls are showing in the book' Boolean readWrite Player getPageControlsShowing Player setPageControlsShowing:) (slot pageControlsShort 'Whether page controls are shown in short form' Boolean readWrite Player getPageControlsShort Player setPageControlsShort:) (slot pageControlsAtTop 'Whether page controls are shown at the top of the book' Boolean readWrite Player getPageControlsAtTop Player setPageControlsAtTop:) (command revertPage 'revert to the original version of this page') (command revertAllPages 'revert the entire book to its original contents') )))! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 8/15/2007 20:26'! getPageControlsAtTop "Answer whether the book is currently set to show page controls at top." | aBook | ^ (aBook _ self bookEmbodied) ifNotNil: [aBook pageControlsAtTop] ifNil: [false]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 8/15/2007 20:26'! getPageControlsShort "Answer whether the book is currentset to show short page controls" | aBook | ^ (aBook _ self bookEmbodied) ifNotNil: [aBook pageControlsShort] ifNil: [false]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 8/15/2007 20:21'! getPageControlsShowing "Answer whether the book is current showing page-controls" | aBook | ^ (aBook _ self bookEmbodied) ifNotNil: [aBook pageControlsVisible] ifNil: [false]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 8/15/2007 20:26'! setPageControlsAtTop: aBoolean "Set whether the book should show page controls at top." | aBook | ^ (aBook _ self bookEmbodied) ifNotNil: [aBook pageControlsAtTop: aBoolean]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 8/15/2007 20:25'! setPageControlsShort: aBoolean "Set whether the book is set for short page controls currently" | aBook | ^ (aBook _ self bookEmbodied) ifNotNil: [aBook pageControlsShort: aBoolean]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 8/15/2007 20:24'! setPageControlsShowing: aBoolean "Answer whether the book is current showing page-controls" | aBook | ^ (aBook _ self bookEmbodied) ifNotNil: [aBoolean ifTrue: [aBook showPageControls] ifFalse: [aBook hidePageControls]]! ! BookMorph removeSelector: #pageControlShort:!