cg@809: " cg@809: COPYRIGHT (c) 1997 by eXept Software AG cg@2621: All Rights Reserved cg@809: cg@809: This software is furnished under a license and may be used cg@809: only in accordance with the terms of that license and with the cg@809: inclusion of the above copyright notice. This software may not cg@809: be provided or otherwise made available to, or used by, any cg@809: other person. No title to or ownership of the software is cg@809: hereby transferred. cg@809: " cg@809: cg@809: cg@809: cg@2621: "{ NameSpace: Tools }" ca@34: cg@1213: SelectionInListView subclass:#NewInspectorListView ca@39: instanceVariableNames:'actionHolder inspectorList includesSelf' ca@34: classVariableNames:'' ca@34: poolDictionaries:'' cg@1213: category:'Interface-NewInspector' ca@34: ! ca@34: cg@1213: !NewInspectorListView class methodsFor:'documentation'! ca@34: cg@809: copyright cg@809: " cg@809: COPYRIGHT (c) 1997 by eXept Software AG cg@2621: All Rights Reserved cg@809: cg@809: This software is furnished under a license and may be used cg@809: only in accordance with the terms of that license and with the cg@809: inclusion of the above copyright notice. This software may not cg@809: be provided or otherwise made available to, or used by, any cg@809: other person. No title to or ownership of the software is cg@809: hereby transferred. cg@809: " cg@809: cg@809: cg@809: ! cg@809: ca@34: examples ca@34: " cg@2621: open a list view on an instance cg@2621: [exBegin] cg@2621: |top slv a| ca@34: cg@2621: a := OrderedCollection new. cg@2621: a add:1. ca@34: cg@2621: top := StandardSystemView new cg@2621: label:'select'; cg@2621: extent:200@200. ca@34: cg@2621: slv := ScrollableView for:self in:top. cg@2621: slv origin:0.0@0.0 corner:1.0@1.0. cg@2621: slv := slv scrolledView. cg@2621: slv inspect:top. cg@2621: slv action:[:el|Transcript showCR:(el printString)]. cg@2621: top open cg@2621: [exEnd] ca@34: " ca@34: ! ! ca@34: cg@1213: !NewInspectorListView methodsFor:'accessing'! ca@34: ca@34: includesSelf:aBool ca@34: includesSelf := aBool ca@34: ! ca@34: ca@39: list ca@39: ^ inspectorList ca@34: ! ca@34: ca@39: list:aList ca@39: "set the lists contents from another list ca@34: " ca@39: aList notNil ifTrue:[inspectorList := aList list] cg@2621: ifFalse:[inspectorList := NewInspectorList new]. ca@34: ca@39: inspectorList includesSelf:includesSelf. ca@39: super list:(inspectorList instanceNames). ca@34: ! ca@34: ca@39: update ca@39: "update the current list ca@34: " ca@39: inspectorList update. ca@39: super list:(inspectorList instanceNames). ca@34: ca@34: ! ! ca@34: cg@1213: !NewInspectorListView methodsFor:'accessing actions'! ca@34: ca@39: action:aOneArgAction ca@39: "set the single click action block. If non-nil, that one is evaluated on single ca@39: click, passing the selected instance as argument ca@34: " ca@39: actionHolder := aOneArgAction ca@34: ! ! ca@34: cg@1213: !NewInspectorListView methodsFor:'drawing'! ca@34: ca@34: drawVisibleLineSelected:visLineNr with:fg and:bg ca@39: "redraw a single line as selected. ca@39: " cg@2621: |nr| ca@34: ca@34: (nr := self visibleLineToListLine:visLineNr) notNil ifTrue:[ cg@2621: ^ self drawVisibleLine:visLineNr with:fg and:bg. ca@34: ]. ca@34: ^ super drawVisibleLine:visLineNr with:fg and:bg ca@34: ca@34: ! ca@34: ca@34: redrawArrowVisibleLine:visLineNr ca@39: "draw a right arrow for visible line ca@39: " ca@34: |nr| ca@34: ca@34: nr := self visibleLineToListLine:visLineNr. ca@34: ca@39: (inspectorList instanceTypeAt:nr) == #directory ifTrue:[ cg@2621: self drawRightArrowInVisibleLine:visLineNr ca@34: ] ca@34: ca@34: ca@34: ! ca@34: ca@34: redrawFromVisibleLine:startVisLineNr to:endVisLineNr ca@34: "redefined to look for directory in every line ca@34: " ca@34: super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. ca@34: ca@34: startVisLineNr to:endVisLineNr do:[:visLineNr| cg@2621: self redrawArrowVisibleLine:visLineNr ca@34: ] ca@34: ! ca@34: ca@34: redrawVisibleLine:visLineNr ca@34: "if the line is one for a directory, draw a right arrow ca@34: " ca@34: super redrawVisibleLine:visLineNr. ca@34: self redrawArrowVisibleLine:visLineNr. ca@34: ! ca@34: ca@34: visibleLineNeedsSpecialCare:visLineNr ca@39: "returns true if the visible line needs special care ca@39: " ca@34: |nr| ca@34: cg@327: nr := self visibleLineToListLine:visLineNr. cg@327: ca@39: (inspectorList instanceTypeAt:nr) == #directory ifTrue:[ cg@2621: ^ true ca@34: ]. ca@34: ^ super visibleLineNeedsSpecialCare:visLineNr ca@34: ca@34: ! ca@34: ca@34: widthForScrollBetween:firstLine and:lastLine ca@34: "return the width in pixels for a scroll between firstLine and lastLine ca@34: - return full width here since there might be directory marks ca@34: " ca@34: ^ (width - margin - margin) ca@34: ca@34: ca@34: ! ! ca@34: cg@1213: !NewInspectorListView methodsFor:'event handling'! ca@34: ca@34: sizeChanged:how ca@39: "redraw marks ca@39: " ca@34: super sizeChanged:how. ca@34: shown ifTrue:[self invalidate] ca@34: ca@34: ! ! ca@34: cg@1213: !NewInspectorListView methodsFor:'initialization'! ca@34: ca@34: initialize ca@34: "initialization ca@34: " ca@34: super initialize. ca@34: ca@34: ignoreReselect := false. ca@34: includesSelf := false. ca@34: actionHolder := [:el|]. cg@1213: inspectorList := NewInspectorList new. ca@34: ca@34: actionBlock := [:dummy| cg@2621: self setSelection:selection. cg@2621: actionHolder value:(self selectedInstanceVar) ca@34: ]. ca@34: ! ! ca@34: cg@1213: !NewInspectorListView methodsFor:'private'! ca@34: ca@39: doesNotUnderstand:aMessage ca@39: "forward a message to the inspectorList ca@34: " ca@39: (inspectorList respondsTo:(aMessage selector)) ifTrue:[ cg@2621: ^ aMessage sendTo:inspectorList ca@39: ]. ca@39: ^ super doesNotUnderstand:aMessage ca@39: ca@39: ca@39: ! ca@39: ca@39: list:aCollection keepSelection:aBoolean ca@39: "set the list - redefined, since setting the list implies unselecting ca@39: and clearing attributes." ca@39: ca@39: "somewhat of a kludge: if selection is first line, ca@39: we have to remove the highlight frame by hand here" ca@39: ca@39: (shown and:[hilightLevel ~~ 0]) ifTrue:[ cg@2621: selection == firstLineShown ifTrue:[ cg@2621: self paint:bgColor. cg@2621: self fillRectangleX:margin y:margin cg@2621: width:(width - (margin * 2)) cg@2621: height:(hilightLevel abs). cg@2621: ]. ca@39: ]. ca@39: listAttributes := nil. ca@39: super list:aCollection expandTabs:false. ca@39: super setSelection:(inspectorList selection). ca@39: ca@39: ca@39: ca@39: ca@34: ! ! ca@34: cg@1213: !NewInspectorListView methodsFor:'selections'! ca@34: ca@39: setSelection:aNumberOrNil ca@39: "select line, aNumber or deselect if argument is nil ca@39: " ca@39: |oldSize| ca@39: ca@39: oldSize := inspectorList size. ca@39: inspectorList setSelection:aNumberOrNil. ca@39: oldSize == inspectorList size ifTrue:[super setSelection:(inspectorList selection)] cg@2621: ifFalse:[super list:(inspectorList instanceNames)]. ca@39: ! ! ca@39: cg@1213: !NewInspectorListView methodsFor:'user interaction'! ca@39: ca@39: accept:aText notifying:aView ca@39: "evaluating aText on the selected instance var; if an error occurs #Error ca@39: is returned otherwise the inspected object instance. On success the list ca@39: will be updated. ca@34: " ca@39: |res| ca@39: ca@39: res := inspectorList accept:aText notifying:aView. ca@39: ca@39: res ~~ #Error ifTrue:[ cg@2621: super list:(inspectorList instanceNames) ca@39: ]. ca@39: ^ res ca@39: ! ca@39: ca@39: doIt:aCode notifying:aView ca@39: "evaluating aCode on the selected instance var; if an error occurs #Error ca@39: is returned otherwise the result returned from the evaluator. On success ca@39: the list will be updated. ca@39: " ca@39: |res| ca@39: ca@39: res := inspectorList doIt:aCode notifying:aView. ca@39: ca@39: res ~~ #Error ifTrue:[ cg@2621: super list:(inspectorList instanceNames) ca@39: ]. ca@39: ^ res ca@34: ca@34: ! ca@34: ca@39: inspect:anObject ca@39: "inspect a new instance; update contents ca@34: " ca@39: (inspectorList inspectedObject) == anObject ifTrue:[ cg@2621: ^ self update ca@39: ]. cg@1286: inspectorList := NewInspectorList for:anObject. ca@39: inspectorList includesSelf:includesSelf. ca@34: ca@39: super list:(inspectorList instanceNames). ca@34: ! ! ca@34: cg@1213: !NewInspectorListView class methodsFor:'documentation'! ca@34: ca@34: version ca@34: ^ '$Header$' ca@34: ! !