# HG changeset patch # User Claus Gittinger # Date 1576172103 -3600 # Node ID 80a909e9841c3054f798a471eacb39905f7e8bd2 # Parent 2182c6e411dcae124eb8f942bf22538eef998f84 #FEATURE by cg class: SmallSense::CriticsWindow class definition added: #annotationLineNr #annotationLineNr: #processOutsideButtonEventWhileModal: #service #service: changed: #processEvent: class: SmallSense::CriticsWindow class added: #documentation #examples diff -r 2182c6e411dc -r 80a909e9841c SmallSense__CriticsWindow.st --- a/SmallSense__CriticsWindow.st Tue Dec 10 14:59:54 2019 +0100 +++ b/SmallSense__CriticsWindow.st Thu Dec 12 18:35:03 2019 +0100 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE Copyright (C) 2013-2014 Jan Vrany @@ -22,7 +24,7 @@ SimpleDialog subclass:#CriticsWindow instanceVariableNames:'ruleHolder ruleRationaleAndFixesHTMLHolder rationalView fixer - entered codeView closeOnLeave' + entered codeView closeOnLeave service annotationLineNr' classVariableNames:'' poolDictionaries:'' category:'SmallSense-Core-Interface' @@ -49,6 +51,58 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA " +! + +documentation +" + documentation to be added. + + class: + + + responsibilities: + + + collaborators: + + + API: + + + example: + + + implementation: + + + [author:] + cg + + [instance variables:] + + [class variables:] + + [see also:] + +" +! + +examples +" + Notice that everything between [exBegin] and [exEnd] is extracted by the html-doc generator + to create nicely formatted and clickable executable examples in the generated html-doc. + (see the browser's class-documentation menu items for more) + + opening the application: + [exBegin] + SmallSense::CriticsWindow open + [exEnd] + + opening the application on some model: + [exBegin] + SmallSense::CriticsWindow openOn:aModel + [exEnd] +" ! ! !CriticsWindow class methodsFor:'help specs'! @@ -196,6 +250,18 @@ !CriticsWindow methodsFor:'accessing'! +annotationLineNr + "the lineNr of my annotation in the gutter" + + ^ annotationLineNr +! + +annotationLineNr:anInteger + "the lineNr of my annotation in the gutter" + + annotationLineNr := anInteger. +! + closeOnLeave "set if used as a flyBy tooltip, which should close automatically. false, if used as a modal dialog, which needs explicit close. @@ -236,6 +302,18 @@ ^self ruleHolder value: anRBLintRule "Created: / 30-01-2012 / 21:45:25 / Jan Vrany " +! + +service + "the (SmallLint-) service which opened me" + + ^ service +! + +service:aSmallLintService + "the service which opened me" + + service := aSmallLintService. ! ! !CriticsWindow methodsFor:'actions'! @@ -578,29 +656,42 @@ !CriticsWindow methodsFor:'event processing'! processEvent: anEvent + "because I am a modal popup, I will get events for all windows. + Return true if handled, false if not." + + |v| + "/ always stay on top (anEvent isPointerEnterLeaveEvent - or:[ anEvent isFocusEvent - or:[ anEvent view notNil and:[ anEvent view isComponentOf:codeView topView ]]]) ifTrue:[ - self window raise. + or:[ anEvent isFocusEvent + or:[ (v := anEvent view) notNil and:[ v isComponentOf:codeView topView ]]] + ) ifTrue:[ + self window raise. + ]. + + anEvent isButtonPressEvent ifTrue:[ + anEvent view == codeView gutterView ifTrue:[ + self halt. + ^ true + ]. ]. anEvent isKeyReleaseEvent ifTrue:[ - anEvent key == #Escape ifTrue:[ - self closeRequest. "/ closeDownViews. - ^true. - ]. + anEvent key == #Escape ifTrue:[ + self closeRequest. "/ closeDownViews. + ^ true. + ]. ]. "/ cg: if this is a modal dialog - do not exit on leave. "/ if used as a flyBy, set the closeOnLeave flag. self closeOnLeave ifTrue:[ - anEvent isPointerLeaveEvent ifTrue:[ - anEvent view == self window ifTrue:[ - self closeRequest. "/ closeDownViews. - ^true. - ] - ]. + anEvent isPointerLeaveEvent ifTrue:[ + anEvent view == self window ifTrue:[ + self closeRequest. "/ closeDownViews. + ^true. + ] + ]. ]. ^false @@ -608,6 +699,24 @@ "Created: / 16-02-2012 / 14:09:33 / Jan Vrany" "Modified (format): / 31-03-2014 / 16:53:41 / Jan Vrany" "Modified (comment): / 18-03-2017 / 14:26:11 / cg" +! + +processOutsideButtonEventWhileModal:anEvent + |lineNr| + + anEvent view == codeView gutterView ifTrue:[ + lineNr := codeView yVisibleToLineNr:anEvent y. + lineNr notNil ifTrue:[ + lineNr == annotationLineNr ifTrue:[ + "/ clicked on my annotation - close me + self hide. + ] ifFalse:[ + "/ close me and open another (by telling my service) + ]. + ]. + ^ true + ]. + ^ false ! ! !CriticsWindow methodsFor:'hooks'! @@ -667,3 +776,4 @@ version_SVN ^ '$Id$' ! ! +