'From etoys2.2 of 21 September 2007 [latest update: #1685] on 9 October 2007 at 3:49:47 pm'! "Change Set: QuickIndex2-tk Date: 9 October 2007 Author: Ted Kaehler Allow the index to be read as a .pr file in QuickGuides. The new index MUST be named 'index.pr' with no version number. Wrote code to allow the buttons in the index page to bring up a short menu of the guides in that category. Will not be used until there is an Index project that knows to call it. QuickGuideGenerator puts new files in a folder called Newest, not in the QuickGuides folder. "! !QuickGuideGenerator commentStamp: 'tk 10/9/2007 13:36' prior: 0! Generate the .sexp files for the Quick Guides for the help system for etoys. Take .pr files in the chosen folder, read in, convert to .sexp and compress and put in folder 'Newer'. User puts these into filder QuickGuides to see them in the system. Click the help button on the top left of the menu bar. .sexp is Yoshiki's new S-expression linearization of object trees.! !BooklikeMorph methodsFor: 'page controls' stamp: 'tk 10/5/2007 19:12'! makeDescriptionViewer | descriptionItem font box | font _ Preferences standardMenuFont. descriptionItem := UpdatingStringMorph new. descriptionItem target: self; getSelector: #descriptionReport. descriptionItem useStringFormat. descriptionItem font: font. box _ Morph new. box color: Color transparent. box layoutPolicy: TableLayout new. box vResizing: #rigid. box hResizing: #rigid. box color: (Color r: 0.839 g: 1.0 b: 0.806). box borderWidth: 1. box borderColor: (Color r: 0.645 g: 0.774 b: 0.613). box cellInset: 3. box cellPositioning: #center. box listCentering: #center. box wrapCentering: #center. box width: (font widthOfString: (String new: 14 withAll: $M)). box height: font height + 4. box addMorph: descriptionItem. "box on: #mouseUp send: #showDescriptionMenu: to: self." ^ box! ! !BooklikeMorph methodsFor: 'page controls' stamp: 'tk 10/5/2007 19:16'! makePageControlsFrom: controlSpecs allowDragging: aBoolean "From the controlSpecs, create a set of page control and return them -- this method does *not* add the controls to the receiver." | col row b lastGuy barColor buttonColor | barColor _ (color brightness > 0.5) ifTrue: [color darker] ifFalse: [color lighter]. buttonColor _ (color brightness > 0.5) ifTrue: [color twiceDarker] ifFalse: [color twiceLighter]. col _ AlignmentMorph newColumn. col color: barColor; borderWidth: 0; layoutInset: 0. col hResizing: #spaceFill; vResizing: #shrinkWrap; extent: 5@5. row _ AlignmentMorph newRow beTransparent. row borderWidth: 0; layoutInset: 0. row hResizing: #spaceFill; vResizing: #shrinkWrap; extent: 5@5. aBoolean ifTrue: [row on: #mouseDown send: #moveViaTitle to: self]. controlSpecs do: [:spec | spec == #showDescription ifTrue: [row addMorphBack: self makeDescriptionViewer]. spec == #pageNumber ifTrue: [row addMorphBack: self makePageNumberItem]. spec == #spacer ifTrue: [row addTransparentSpacerOfSize: (3 @ 0)]. spec == #variableSpacer ifTrue: [ row addMorphBack: AlignmentMorph newVariableTransparentSpacer]. spec class == Array ifTrue: [ spec first isSymbol ifTrue: [b := ThreePhaseButtonMorph labelSymbol: spec first] ifFalse: [b := SimpleButtonMorph new borderWidth: 2; borderColor: Color black; color: buttonColor. b label: spec first font: Preferences standardMenuFont]. b target: self; actionSelector: spec second; setBalloonText: spec third. (spec atPin: 4) = #border ifTrue: [b actWhen: #buttonDown] ifFalse: [b borderWidth: 0]. "default is none" row addMorphBack: b. (((lastGuy _ spec last asLowercase) includesSubString: 'menu') or: [lastGuy includesSubString: 'designations']) ifTrue: [b actWhen: #buttonDown]]]. "pop up menu on mouseDown" col addMorphBack: row. ^ col! ! !QuickGuideGenerator methodsFor: 'all' stamp: 'tk 10/9/2007 15:49'! generate | inDir outDir | inDir _ FileDirectory on: input. inDir fileNames ifEmpty: [ self inform: 'the input path doesn''t point to\the directory with projects' withCRs. ^ self]. outDir _ FileDirectory on: output. outDir assureExistence. outDir fileNames ifNotEmpty: [ "self halt. let me see what is in it!!" self inform: 'output directory is not empty.\Please remove files in it first.' withCRs. ^ self]. QuickGuideMorph convertProjectsWithBooksToSISSIn: inDir to: outDir. ! ! !QuickGuideGenerator methodsFor: 'all' stamp: 'tk 10/9/2007 13:32'! initialize super initialize. input _ ''. output _ (FileDirectory on: Smalltalk imagePath) fullPathFor: 'Newest'. self setup. ! ! !QuickGuideMorph methodsFor: 'initialization' stamp: 'tk 10/9/2007 13:58'! initializeIndexPage | indexPage firstPage | "debugging only -- look on disk" self class checkForIndexOnDisk. "sets IndexPage every time if found" IndexPage ifNil: [ self class initializeIndexPageFrom: IndexPageMimeString. ]. IndexPage ifNotNil: [ indexPage _ IndexPage veryDeepCopy. firstPage _ pages first. indexPage position: firstPage position. indexPage beSticky. firstPage extent: indexPage extent. firstPage addMorph: indexPage. self goToPage: 1. ]. ! ! !QuickGuideMorph methodsFor: 'menu actions' stamp: 'tk 10/5/2007 19:01'! showMenuCategory: catName "put up a menu with all guides in this category" | subMenu | subMenu _ MenuMorph new defaultTarget: self. subMenu addTitle: catName translated. (self class defaultOrderIn: catName) do: [:ee | subMenu add: ee target: self selector: #goToCardNamed: argument: ee]. subMenu popUpInWorld.! ! !QuickGuideMorph class methodsFor: 'initialization' stamp: 'tk 10/9/2007 14:14'! checkForIndexOnDisk "For debugging only, Look on disk every time for a new Index as a .pr file. Must be named index.pr. Overwrite IndexPage if found." | dir | dir _ (FileDirectory on: Smalltalk imagePath) directoryNamed: 'QuickGuides'. (dir fileExists: 'index.pr') ifFalse: [^ self]. IndexPage _ QuickGuideHolderMorph new loadPR: 'index.pr' dir: dir.! !