'From VisualWorks® NonCommercial, Release 5i.4 of August 9, 2001 on June 6, 2002 at 6:06:38 pm'! CormasNS.Kernel defineClass: #Legend superclass: #{UI.Model} indexedType: #none private: false instanceVariableNames: 'legendes isOpen yWin xWin currentWinPos mainInterface ' classInstanceVariableNames: '' imports: '' category: 'CormasKernel-Tools'! !CormasNS.Kernel.Legend methodsFor: 'initialisation'! init "comment stating purpose of message" legendes := OrderedCollection new. isOpen := false. currentWinPos := 360@10.! ! !CormasNS.Kernel.Legend methodsFor: 'actions'! addLegend: classMethod location: pos "classMethod = an Array ex:#(MyCell 'pov') pos = " | class legend legendList l max str widths winWidth color tempStr | max := 0. widths := Array new: 2. legendList := OrderedCollection new. class := self mainInterface model cormasModel class environment at: (classMethod at: 1) asSymbol. (self mainInterface model cormasModel class visualizedClasses includes: class) ifFalse: [self halt]. (class pdvDict at: (classMethod at: 2) asSymbol) do: [:symbol | tempStr := symbol. (class colorsDict includesKey: symbol) ifFalse: [tempStr := tempStr , ' (undefined)']. legendList add: tempStr. max < tempStr size ifTrue: [max := tempStr size. str := tempStr]. legendList add: '']. legend := LegendWin new. legend init: classMethod. legend legendes: self. legend affectLegend: legendList. legend ouvrirVue. (legend builder componentAt: #pdvMethod) widget labelString: (classMethod at: 2). self mainInterface builder window beMaster. (legend builder window) application: self mainInterface builder window application; beSlave. legend builder window label: 'legend: ' , (classMethod at: 1). legendes add: legend. l := 0. (class pdvDict at: (classMethod at: 2) asSymbol) do: [:symbol | l := l + 1. (class colorsDict includesKey: symbol) ifTrue: [color := class colorsDict at: symbol] ifFalse: [color := ColorValue white]. legend tableInterface backgroundColorAtIndex: 2 @ l put: color]. widths at: 1 put: (legend builder window graphicsContext widthOfString: str). widths at: 2 put: 30. legend tableInterface columnWidths: widths. (legend builder window graphicsContext widthOfString: (classMethod at: 2)) > (30 + (widths at: 1)) ifTrue: [winWidth := legend builder window graphicsContext widthOfString: (classMethod at: 2)] ifFalse: [winWidth := 30 + (widths at: 1)]. winWidth := winWidth + 40. legend builder window displayBox: (pos extent: winWidth @ (60 + (legendList size * 11))). ((self mainInterface menuHolder value atNameKey: #tools) submenu atNameKey: #activateLegend) isOn ifTrue: [legend builder window openIn: legend builder window displayBox. legend isOpened: true] ifFalse: [legend isOpened: false]! majLegendes: classMethod "classMethod = an Array ex:#(MyCell 'pov')" | classe methode found posFound | classe := classMethod at: 1. methode := classMethod at: 2. found := legendes detect: [:leg | leg classe = classe] ifNone: [nil]. found = nil ifFalse: [found methode = methode ifFalse: [methode = 'nil' ifFalse: [posFound := found builder window displayBox origin. self removeLegend: found. self addLegend: classMethod location: posFound.] ifTrue: [found builder window displayBox origin = currentWinPos ifTrue: [currentWinPos := (currentWinPos x - 10) @ (currentWinPos y - 30)]. self removeLegend: found]]] ifTrue: [methode = 'nil' ifFalse: [currentWinPos := (currentWinPos x + 10) @ (currentWinPos y + 30). self addLegend: classMethod location: currentWinPos]]! removeLegend: aLegendWin "comment stating purpose of message" | | aLegendWin closeRequest! ! !CormasNS.Kernel.Legend methodsFor: 'acces'! isOpen ^isOpen! legendes "comment stating purpose of message" ^legendes! legendes:x "comment stating purpose of message" legendes:=x! mainInterface ^mainInterface! mainInterface: x mainInterface := x! supervisor: x "comment stating purpose of message" mainInterface := x! !