'From Moshi of 3 March 2007 [latest update: #1931] on 18 January 2011 at 4:30:52 pm'!"Change Set:		LObj-BW-tkDate:			18 January 2011Author:			Ted KaehlerRe-do menu creation.  Now can create a menu from lists.  Good when the menu contents is computed.LBox newMenuLabels: labels targets: targets selectors: selectors args: argssUsed it in core sample to make it simpler.Allow title of a document in Frank to be editable.stackName in the document stores the title string.The title is set in installDocument: by	docEd title textContents: docStk stackName.To read the title as a text string, say (docStk stackName)."!!LBox class methodsFor: 'instance creation' stamp: 'tk 1/18/2011 11:03'!newMenuLabels: labels targets: targets selectors: selectors args: argss	"Construct and show a menu with labels, targets, selectors, args  Easier to construct dynamic menus than the spec format with one row per item."	| bt mbw mi mc |	bt := LBox newMenu.	mbw := targets first valueOfProperty: #menuBorderWidth ifAbsent: [2].	1 to: targets size do: [:ii |		mi := LBox newListItem: (labels at: ii)				target: (targets at: ii)				selector: (selectors at: ii)				argument: (argss at: ii)				for: bt.		bt add: mi].	mc := targets first valueOfProperty: #menuColor ifAbsent: [Color gray: 0.875].	bt color: mc; borderWidth: mbw.	bt layout layOut: bt.	bt forceWithinContainer.	LBoxHandleInvoker installTo: bt.	^ bt! !!LDBJrDemo class methodsFor: 'ToolBar Demo' stamp: 'tk 1/18/2011 15:47'!docSample1: docStk	"Fill a page with text and images"	| fldBox docCostume yy |	docCostume := docStk costume.	fldBox :=  LWordWrapLayoutF openTextField.	fldBox name: 'textBox1'; borderWidth: 0.	fldBox layout font: LFamily defaultFont.	"9 point"	fldBox layout inset: 5@6.	fldBox topLeft: 0@0; extent: 700 "docCostume width" @ (yy := 30).	docStk page ouGenericCardClass classPool at: #PageTurnInProgress put: true.	docCostume add: fldBox.	docStk page beInCard: fldBox.	docStk page ouGenericCardClass classPool at: #PageTurnInProgress put: false.	fldBox layout storeString: 'Previous STEPS Results'.	fldBox layout charTypedCMDa.  fldBox layout charTypedCMDb.	fldBox :=  LWordWrapLayoutF openTextField.	fldBox name: 'textBox2'; borderWidth: 0.	fldBox layout font: LFamily defaultFont.	"9 point"	fldBox layout inset: 5@6.	fldBox topLeft: 0@yy; extent: 700 "docCostume width" @ 65.	yy := yy + fldBox height.	docStk page ouGenericCardClass classPool at: #PageTurnInProgress put: true.	docCostume add: fldBox.	docStk page beInCard: fldBox.	docStk page ouGenericCardClass classPool at: #PageTurnInProgress put: false.	fldBox layout storeString: 'The first three years were devoted to making much smaller, simpler, and more readable versions of many of the prime parts of personal computing, including: graphics and sound, viewing/windowing, UIs, text, composition, cells, TCP/IP, etc. These have turned out well (they are chronicled in previous NSF reports and in our papers and memos).'.	fldBox :=  LWordWrapLayoutF openTextField.	fldBox name: 'textBox3'; borderWidth: 0.	fldBox layout font: LFamily defaultFont.	"9 point"	fldBox layout inset: 5@6.	fldBox topLeft: 0@yy; extent: 700 "docCostume width" @ 65.	yy := yy + fldBox height.	docStk page ouGenericCardClass classPool at: #PageTurnInProgress put: true.	docCostume add: fldBox.	docStk page beInCard: fldBox.	docStk page ouGenericCardClass classPool at: #PageTurnInProgress put: false.	fldBox layout storeString: 'For example, essentially all of standard personal computing graphics can be created from scratch in the Nile language in a little more than 300 lines of code. Nile itself can be made in a little over 100 lines of code in the OMeta metalanguage, and optimized to run acceptably in real-time (also in OMeta) in another 700 lines. OMeta can be made in itself and optimized in about 100 lines of code.'.	yy := yy + (self insertImageFile: 'Ometa-Ometa.bmp' at: 15@yy in: docStk).	yy := yy + 15.	yy := yy + (self insertImageFile: 'Ometa-Nile.bmp' at: 15@yy in: docStk).	docStk stackName: 'Simple UI Panel for STEPS'.! !!LDocEditor methodsFor: 'initialize-release' stamp: 'tk 1/18/2011 15:48'!createIn: anLWindow	"		LDocEditor docEdDemo		"	| tbStk nn |	whole := LBox new.	whole extent: anLWindow extent - (40@40).	whole color: Color white; borderWidth: 0; name: 'documentEditor'.	self installTo: whole.	anLWindow add: whole.	self setTheme: #orange.	tbStk := self toolBarStack: whole.	"add a stack in the upper part"	docStack := self docStack: whole.	"sets mainView"	docPane := docStack costume.	self spillOverStack: whole.			"where spill-over menus live"	LDBJrDemo docSample1: docStack.	docStack page insertPage.	"will want to put fields and text on page 2"	docStack showPageNumber: 1.	self title textContents: docStack stackName.	thumbList := self thumbNailStrip: whole.	scriptPane := self scriptPane: whole.	nn := 0.	self fillMailPage: (nn := nn +1).	"In & Out"	self fillDocPage: (nn := nn +1).	self fillInsertPage: (nn := nn +1).	self fillContentPage: (nn := nn +1).	self fillShapePage: (nn := nn +1).	"Shape"	self fillScriptPage: (nn := nn +1).	self fillControlPage: (nn := nn +1).	self fillSensingPage: (nn := nn +1).	self fillOperatorsPage: (nn := nn +1).	self fillPenPage: (nn := nn +1).	tbStk showPageNumber: 1.	whole addAsParts: self toggleFullscreenButton.	whole addAsParts: self toggleScriptPaneButton.	whole addAsParts: self toggleThumbListButton.	anLWindow on: LBoxDeleted to: self.	docPane on: LExtentChanged to: self.	"occupy full-screen"	anLWindow		layout: (LSimpleLayout new			keep: #topLeft of: whole name to: #topLeft;			keep: #extent of: whole name to: #extent);		layoutChanged.	self toggleFullScreen: false.! !!LDocEditor methodsFor: 'initialize-release' stamp: 'tk 1/18/2011 15:37'!docStack: docEd	"A large stack at the bottom for documents"	| docCostume docStk lf |	mainView := self mainView: docEd.	docEd add: mainView.	docCostume := LBox extent: self defaultDocExtent color: Color white.	LBoxHandleInvoker installTo: docCostume.	(LDropHandler new installTo: docCostume) highlightFill: nil.	mainView add: docCostume.	mainView on: LExtentChanged to: (docCostume install: LDocViewer).	docCostume borderWidth: 1; borderColor: edgeColor. 	docCostume clipping: true; name: 'theDocs'.	(lf := LLastFocusHandler new) installTo: docCostume.	docEd topContainer worldState hand on: LKeyboardFocusChanged to: lf.	docStk := LDBJrStack newAround: docCostume. 	"Create Stack !!!!"	docStk stackName: 'New Document'.	self title textContents: docStk stackName.	docStk setProperty: #namespace toValue: docStk.	docStk setProperty: #objectsPool toValue: IdentityDictionary new.	docCostume setProperty: #namespace toValue: docStk.	whole topContainer worldState valueAnnouncersList add: docStk.	^ docStk! !!LDocEditor methodsFor: 'initialize-release' stamp: 'tk 1/18/2011 16:16'!toolBarAddTitleFld	"Install a title field.  Shared text,  In front of tool bar category row on right edge."	| titleFld tbStk |	titleFld := LBox new.	LLineEditor new installInField: titleFld.	titleFld textContents: 'New Document'; pivotRatio: 0@0.7.	titleFld color: Color transparent; name: 'title'; extent: 200@18.	LBoxHandleInvoker installTo: titleFld.	titleFld on: LContentAccepted send: #docTitle:from: to: self.	tbStk := toolBar stackIAmBackgroundOf.	tbStk page ouGenericCardClass classPool at: #PageTurnInProgress put: true.	toolBar addFirst: titleFld.	tbStk page class beSharedText: titleFld.	"title is shared on all toolBar pages"	tbStk page ouGenericCardClass classPool at: #PageTurnInProgress put: false.	toolBar layout keep: #topRight of: 'title' to: #topRight offset: -20@3.		^ titleFld	" font: LFamily defaultFont."	"9 point"! !!LDocEditor methodsFor: 'events' stamp: 'tk 1/18/2011 16:18'!docTitle: newTitleAnn from: typeInBox		docStack stackName: newTitleAnn content! !!LDocEditor methodsFor: 'events' stamp: 'tk 1/18/2011 15:52'!installDocument: newStack	"Install the new stack in the large stack at the bottom of the doc editor.  To test:	| le de |	le := (ActiveWorld findA: LesserphicMorph).	de := le window atName: 'documentEditor'.	(de \ #DocEditor) installDocument: LDBJrDemo testInstallStack.	"	| lf |	docPane delete.	docStack := newStack.	docPane := docStack costume.	(lf := docPane \ #LastFocusHandler) ifNil: [		(lf := LLastFocusHandler new) installTo: docPane].	whole hand on: LKeyboardFocusChanged to: lf.	whole topContainer worldState valueAnnouncersList add: docStack.	LBoxHandleInvoker installTo: docPane.	mainView add: docPane.	mainView on: LExtentChanged to: (docPane install: LDocViewer).	docPane borderWidth: 1; borderColor: edgeColor. 	(docPane \  #DocViewer) adjustScale.	self title textContents: docStack stackName.	thumbList removeAll.	self thumbNailStripFill.	scriptPane ifNotNil: [		scriptPane delete.		scriptPane := self scriptPane: whole].! !!LDocEditor methodsFor: 'accessing' stamp: 'tk 1/18/2011 15:37'!title	"the field that holds the document title.  use textContents: to set it."	^ toolBar stackIAmBackgroundOf page title "a field"! !!LesserphicMorph methodsFor: 'core sample' stamp: 'tk 1/18/2011 11:06'!coreSample: aMorphicEvent	"Present a menu of all boxes under this point.  Open an explorer on the one the user chooses."	| list nameList menu selectors argss |	list := self coreSample: aMorphicEvent position near: window saveIn: LCollection new.	nameList := list collect: [:ii | ii name].	selectors := Array new: list size withAll: #explore.	argss := Array new: list size withAll: nil.	menu :=  LBox newMenuLabels: nameList targets: list selectors: selectors args: argss.	menu name: 'core sample menu'.	LBox invokeMenu: menu near: (aMorphicEvent position - self topLeft) for: window." an LCollection( an LWindow(LWindow) an LBox(documentEditor) an LBox(toolBar) an LBox(toolHolder) an LBox(border) an LBox(border thicker) an LBox #b )"! !!LHaloEdgeHandler methodsFor: 'all' stamp: 'tk 1/18/2011 14:36'!motion: event with: anLObject	| diff |	diff := (event localPointFor: target) - clickPoint.	target container ifNotNil: [		(target container layout isKindOf: LSimpleLayout) ifTrue: [			target container layout move: target name by: diff]].	target translateBy: diff.	event handled: self.! !LBox class removeSelector: #newMenuLabels:targets:selectors:args:near:!