Tools__CodeView2.st
changeset 16890 8b4fad7fb72d
parent 16865 d29d2834b10e
child 16910 83403af26b43
equal deleted inserted replaced
16889:a0d757c7ec2d 16890:8b4fad7fb72d
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
     2  COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
     5               All Rights Reserved
     3               All Rights Reserved
     6 
     4 
     7 Permission is hereby granted, free of charge, to any person
     5 Permission is hereby granted, free of charge, to any person
    40 	poolDictionaries:''
    38 	poolDictionaries:''
    41 	category:'Interface-CodeView'
    39 	category:'Interface-CodeView'
    42 !
    40 !
    43 
    41 
    44 AbstractBackground subclass:#AnnotationShowingScrollerBackground
    42 AbstractBackground subclass:#AnnotationShowingScrollerBackground
    45 	instanceVariableNames:'annotations textView'
    43 	instanceVariableNames:'annotations breakpoints textView'
    46 	classVariableNames:''
    44 	classVariableNames:''
    47 	poolDictionaries:''
    45 	poolDictionaries:''
    48 	privateIn:CodeView2
    46 	privateIn:CodeView2
    49 !
    47 !
    50 
    48 
  1092 
  1090 
  1093 updateScrollersViewBackground
  1091 updateScrollersViewBackground
  1094     "this changes the scroller's background, to show the positions of
  1092     "this changes the scroller's background, to show the positions of
  1095      warnings, for easy location of interesting spots"
  1093      warnings, for easy location of interesting spots"
  1096      
  1094      
  1097     |allAnnotations scroller newBackground|
  1095     |allAnnotations allBreakpoints scroller newBackground|
  1098 
  1096 
  1099     allAnnotations := OrderedCollection new.
  1097     allAnnotations := OrderedCollection new.
       
  1098     allBreakpoints := OrderedCollection new.
  1100     services do:[:eachService |
  1099     services do:[:eachService |
  1101         allAnnotations addAll:(eachService annotations ? #())
  1100         allAnnotations addAll:(eachService annotations ? #()).
       
  1101         eachService isBreakpointService ifTrue:[
       
  1102             allBreakpoints addAll:(eachService breakpoints ? #()).
       
  1103         ].    
  1102     ].
  1104     ].
  1103 
  1105 
  1104     scroller := textViewScroller verticalScrollBar thumb.
  1106     scroller := textViewScroller verticalScrollBar thumb.
  1105     allAnnotations isEmptyOrNil ifTrue:[
  1107     (allAnnotations isEmpty and:[allBreakpoints isEmpty]) ifTrue:[
  1106         "/ nothing special to show
  1108         "/ nothing special to show
  1107         scroller viewBackground isColor ifTrue:[^ self].
  1109         scroller viewBackground isColor ifTrue:[^ self].
  1108         scroller initStyle
  1110         scroller initStyle
  1109     ] ifFalse:[
  1111     ] ifFalse:[
  1110         "/ yep, there are some annotations
  1112         "/ yep, there are some annotations
  1111         newBackground := (AnnotationShowingScrollerBackground new annotations:allAnnotations; textView:textView; yourself ).
  1113         newBackground := AnnotationShowingScrollerBackground new.
       
  1114         newBackground textView:textView.
       
  1115         newBackground annotations:allAnnotations; breakpoints:allBreakpoints.
  1112         scroller viewBackground:newBackground.
  1116         scroller viewBackground:newBackground.
  1113     ].
  1117     ].
  1114     scroller invalidate.
  1118     scroller invalidate.
  1115 ! !
  1119 ! !
  1116 
  1120 
  2290 "
  2294 "
  2291 ! !
  2295 ! !
  2292 
  2296 
  2293 !CodeView2::AnnotationShowingScrollerBackground methodsFor:'accessing'!
  2297 !CodeView2::AnnotationShowingScrollerBackground methodsFor:'accessing'!
  2294 
  2298 
  2295 annotations:something
  2299 annotations:aCollectionOfAnnotations
  2296     annotations := something.
  2300     annotations := aCollectionOfAnnotations.
       
  2301 !
       
  2302 
       
  2303 breakpoints:aCollectionOfBreakpoints
       
  2304     breakpoints := aCollectionOfBreakpoints.
  2297 !
  2305 !
  2298 
  2306 
  2299 textView:something
  2307 textView:something
  2300     textView := something.
  2308     textView := something.
  2301 ! !
  2309 ! !
  2304 
  2312 
  2305 fillRectangleX:x y:y width:w height:h in:aScroller
  2313 fillRectangleX:x y:y width:w height:h in:aScroller
  2306     "I am asked to draw the background of aScroller.
  2314     "I am asked to draw the background of aScroller.
  2307      If any annotation is in that range, draw it"
  2315      If any annotation is in that range, draw it"
  2308     
  2316     
  2309     |overAllHeight|
  2317     |overAllHeight drawRect scrollerHeight|
  2310 
  2318 
  2311     annotations isEmptyOrNil ifTrue:[^ self ].
  2319     annotations isEmptyOrNil ifTrue:[
  2312 
  2320         breakpoints isEmptyOrNil ifTrue:[
       
  2321             ^ self 
       
  2322         ].
       
  2323     ].
       
  2324     
       
  2325     scrollerHeight := aScroller height.
       
  2326     drawRect :=
       
  2327         [:lineNr :clrInside |
       
  2328             |clrBorder yThumb|
       
  2329             
       
  2330             yThumb := (scrollerHeight * (lineNr / overAllHeight)) rounded.
       
  2331             (yThumb between:y-5 and:(y + h + 5)) ifTrue:[
       
  2332                 clrBorder := clrInside darkened.
       
  2333                 aScroller paint:clrInside.
       
  2334                 aScroller fillRectangleX:3 y:(yThumb-5 max:0) width:aScroller width-5 height:8.
       
  2335                 aScroller paint:clrBorder.
       
  2336                 aScroller displayRectangleX:3 y:(yThumb-5 max:0) width:aScroller width-5 height:9.
       
  2337             ].    
       
  2338         ].
       
  2339         
  2313     overAllHeight := textView numberOfLines.
  2340     overAllHeight := textView numberOfLines.
  2314     overAllHeight = 0 ifTrue:[ ^ self ].
  2341     overAllHeight = 0 ifTrue:[ ^ self ].
  2315 
  2342 
  2316     annotations do:[:eachAnnotation |
  2343     annotations notEmptyOrNil ifTrue:[
  2317         |lineNr yThumb baseColor clr1 clr2 severity|
  2344         annotations do:[:eachAnnotation |
  2318 
  2345             |lineNr severityColor severity|
  2319         (lineNr := eachAnnotation line) notNil ifTrue:[    
  2346 
  2320             yThumb := (aScroller height * (lineNr / overAllHeight)) rounded.
  2347             (lineNr := eachAnnotation line) notNil ifTrue:[ 
  2321             (yThumb between:y-5 and:(y + h + 5)) ifTrue:[
       
  2322                 severity := eachAnnotation rule severity.
  2348                 severity := eachAnnotation rule severity.
  2323                 severity == #error ifTrue:[
  2349                 severity == #error ifTrue:[
  2324                     baseColor := Color red.
  2350                     severityColor := Color red.
  2325                 ] ifFalse:[
  2351                 ] ifFalse:[
  2326                     severity == #warning ifTrue:[
  2352                     severity == #warning ifTrue:[
  2327                         baseColor := Color yellow.
  2353                         severityColor := Color yellow.
  2328                     ] ifFalse:[
  2354                     ] ifFalse:[
  2329                         baseColor := Color blue.
  2355                         severityColor := Color blue.
  2330                     ].    
  2356                     ].    
  2331                 ].    
  2357                 ].    
  2332                 clr1 := baseColor lightened lightened.
  2358                 drawRect value:lineNr value:severityColor lightened.
  2333                 clr2 := clr1 darkened.
       
  2334                 aScroller paint:clr1.
       
  2335                 aScroller fillRectangleX:3 y:(yThumb-5 max:0) width:aScroller width-5 height:8.
       
  2336                 aScroller paint:clr2.
       
  2337                 aScroller displayRectangleX:3 y:(yThumb-5 max:0) width:aScroller width-5 height:9.
       
  2338             ].
  2359             ].
  2339         ].
  2360         ].
  2340     ]
  2361     ].
       
  2362     breakpoints notEmptyOrNil ifTrue:[
       
  2363         breakpoints do:[:eachBreakpoint |
       
  2364             (eachBreakpoint isVisible and:[eachBreakpoint isEnabled]) ifTrue:[ 
       
  2365                 |lineNr bpntColor|
       
  2366 
       
  2367                 (lineNr := eachBreakpoint line) notNil ifTrue:[    
       
  2368                     bpntColor := eachBreakpoint isTracepoint
       
  2369                                     ifTrue:[ Color blue lightened]
       
  2370                                     ifFalse:[ Color red ].
       
  2371                     drawRect value:lineNr value:bpntColor.
       
  2372                 ].
       
  2373             ].
       
  2374         ].
       
  2375     ].
  2341 ! !
  2376 ! !
  2342 
  2377 
  2343 !CodeView2::AnnotationShowingScrollerBackground methodsFor:'ignored conversion'!
  2378 !CodeView2::AnnotationShowingScrollerBackground methodsFor:'ignored conversion'!
  2344 
  2379 
  2345 asFormOn:aDevice
  2380 asFormOn:aDevice