NoteBookView.st
changeset 4856 e30db8df7505
parent 4841 749f28290578
child 4885 6a3ec18c4d1b
equal deleted inserted replaced
4854:23fe12653489 4856:e30db8df7505
    28 		showDestroyTabButton destroyTabAction activeTabMarkerColor
    28 		showDestroyTabButton destroyTabAction activeTabMarkerColor
    29 		activeTabMarkerFGColor tabWasActiveWhenPressed removeTabIcon
    29 		activeTabMarkerFGColor tabWasActiveWhenPressed removeTabIcon
    30 		removeTabEnteredIcon removeTabDisabledIcon
    30 		removeTabEnteredIcon removeTabDisabledIcon
    31 		showingEnteredRemoveTabButton lastUserSelection minimumTabWidth
    31 		showingEnteredRemoveTabButton lastUserSelection minimumTabWidth
    32 		addTabAction addTabIcon addTabEnteredIcon addTabDisabledIcon
    32 		addTabAction addTabIcon addTabEnteredIcon addTabDisabledIcon
    33 		showingEnteredAddTabButton'
    33 		showingEnteredAddTabButton canvasLevel'
    34 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    34 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    35 		DefaultActiveForegroundColor DefaultActiveBackgroundColor
    35 		DefaultActiveForegroundColor DefaultActiveBackgroundColor
    36 		DefaultShadowColor DefaultHalfShadowColor DefaultLightColor
    36 		DefaultShadowColor DefaultHalfShadowColor DefaultLightColor
    37 		DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor
    37 		DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor
    38 		DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor
    38 		DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor
  1382     "/ test whether TabView and not NoteBookView
  1382     "/ test whether TabView and not NoteBookView
  1383     tabModus ifTrue:[^ self].
  1383     tabModus ifTrue:[^ self].
  1384 
  1384 
  1385     layout := self computeBorderLayout.
  1385     layout := self computeBorderLayout.
  1386 
  1386 
  1387     tabLevel ~~ 0 ifTrue:[
  1387     ((tabLevel ~~ 0) or:[canvasLevel ~= 0]) ifTrue:[
  1388         self drawEdgesForX:(layout left)
  1388         canvasLevel ~= 0 ifTrue:[
  1389                          y:(layout top)
  1389             self drawEdgesForX:(layout left)
  1390                      width:(layout width) 
  1390                              y:(layout top)
  1391                     height:(layout height)
  1391                          width:(layout width) 
  1392                      level:tabLevel.
  1392                         height:(layout height)
  1393       ^ self
  1393                          level:tabLevel.
  1394     ].
  1394             ^ self
  1395     list size > 1 ifFalse:[^ self].
  1395         ].
  1396 
  1396         "/only draw top-edge
  1397     self paint:lightColor ? lightColor.
  1397         self drawTopEdgeLevel:tabLevel atY:layout top
  1398     trans := self transformation.
  1398              shadow:shadowColor light:lightColor 
  1399 
  1399              halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle.
  1400     (direction == #top or:[direction == #bottom]) ifTrue:[
  1400         ^ self
  1401         direction == #top ifTrue:[ y0 := layout top - 1 ]
  1401     ].
  1402                          ifFalse:[ y0 := layout bottom ].
  1402     
  1403         y1 := y0.
  1403     list size <= 0 ifTrue:[^ self].
  1404         x0 := 0.
  1404 
  1405         trans notNil ifTrue:[
  1405     true "canvasBorder ~~ 0" ifTrue:[
  1406             x0 := trans applyInverseToX:x0.
  1406         self paint:lightColor ? lightColor.
  1407         ].
  1407         
  1408         x1 := x0 + self width.
  1408         trans := self transformation.
  1409     ] ifFalse:[
  1409 
  1410         direction == #left ifTrue:[ x0 := layout left - 1 ]
  1410         (direction == #top or:[direction == #bottom]) ifTrue:[
  1411                           ifFalse:[ x0 := layout right    ].
  1411             direction == #top ifTrue:[ y0 := layout top - 1 ]
  1412         x1 := x0.
  1412                              ifFalse:[ y0 := layout bottom ].
  1413         y0 := 0.
  1413             y1 := y0.
  1414         trans notNil ifTrue:[
  1414             x0 := 0.
  1415             y0 := trans applyInverseToY:y0.
  1415             trans notNil ifTrue:[
  1416         ].
  1416                 x0 := trans applyInverseToX:x0.
  1417         y1 := y0 + self height.
  1417             ].
  1418     ].
  1418             x1 := x0 + self width.
  1419     self displayLineFromX:x0 y:y0 toX:x1 y:y1.
  1419         ] ifFalse:[
       
  1420             direction == #left ifTrue:[ x0 := layout left - 1 ]
       
  1421                               ifFalse:[ x0 := layout right    ].
       
  1422             x1 := x0.
       
  1423             y0 := 0.
       
  1424             trans notNil ifTrue:[
       
  1425                 y0 := trans applyInverseToY:y0.
       
  1426             ].
       
  1427             y1 := y0 + self height.
       
  1428         ].
       
  1429         self displayLineFromX:x0 y:y0 toX:x1 y:y1.
       
  1430     ]
  1420 !
  1431 !
  1421 
  1432 
  1422 drawDestroyButtonForTab:aTab
  1433 drawDestroyButtonForTab:aTab
  1423     "redraw a tab's destroy button"
  1434     "redraw a tab's destroy button"
  1424 
  1435 
  2351 
  2362 
  2352 initStyle
  2363 initStyle
  2353     "setup style attributes
  2364     "setup style attributes
  2354     "
  2365     "
  2355     <resource: #style (#'noteBook.viewBackground' 
  2366     <resource: #style (#'noteBook.viewBackground' 
       
  2367                        #'noteBook.tabTopMargin' 
       
  2368                        #'noteBook.tabBottomMargin'
       
  2369                        #'noteBook.tabLevel'
       
  2370                        #'noteBook.tabLabelInset'
       
  2371                        #'noteBook.canvasInset'
       
  2372                        #'noteBook.canvasBorder'
       
  2373                        #'noteBook.canvasLevel'
  2356                        )>
  2374                        )>
  2357     |clr graphicsDevice|
  2375     |clr graphicsDevice|
  2358 
  2376 
  2359     super initStyle.
  2377     super initStyle.
  2360     graphicsDevice := self graphicsDevice.
  2378     graphicsDevice := self graphicsDevice.
  2422         disabledForegroundColor := drawLightColor
  2440         disabledForegroundColor := drawLightColor
  2423     ].
  2441     ].
  2424 
  2442 
  2425     activeTabMarkerColor := DefaultActiveTabMarkerColor.
  2443     activeTabMarkerColor := DefaultActiveTabMarkerColor.
  2426     activeTabMarkerFGColor := DefaultActiveTabMarkerFgColor.
  2444     activeTabMarkerFGColor := DefaultActiveTabMarkerFgColor.
       
  2445 
       
  2446     canvasInset      := styleSheet at:#'noteBook.canvasInset'      default:1@1.
       
  2447 
       
  2448     tabLevel         := styleSheet at:#'noteBook.tabLevel'         default:1.
       
  2449     tabLabelInset    := styleSheet at:#'noteBook.tabLabelInset'    default:6@4.
       
  2450     selectionInsetX  := (2 max:(tabLevel abs)) + 1.
       
  2451     selectionInsetY  := (2 max:(tabLevel abs)) + 1.
       
  2452 
       
  2453     tabTopMargin    := styleSheet at:#'noteBook.tabTopMargin' default:4.
       
  2454     tabBottomMargin := styleSheet at:#'noteBook.tabBottomMargin' default:1.
       
  2455 
       
  2456     canvasLevel := styleSheet at:#'noteBook.canvasLevel' default:tabLevel.
  2427 !
  2457 !
  2428 
  2458 
  2429 initialize
  2459 initialize
       
  2460 
       
  2461     "/must init first - these values might be overwritten by initStyle
       
  2462     showDestroyTabButton := false.
       
  2463     canvasInset      := 1@1.
       
  2464     keepCanvas       := false.
       
  2465     tabLevel         := 1.
       
  2466     tabLabelInset    := 6@4.
       
  2467     selectionInsetX  := (2 max:(tabLevel abs)) + 1.
       
  2468     selectionInsetY  := (2 max:(tabLevel abs)) + 1.
       
  2469     translateLabel   := false.
       
  2470 
       
  2471     tabRightMargin   := 0.
       
  2472     tabLeftMargin    := 0.
       
  2473 
       
  2474     tabTopMargin     := 4.
       
  2475     tabBottomMargin  := 1.
       
  2476     canvasLevel      := tabLevel.
       
  2477 
       
  2478     showingEnteredRemoveTabButton := showingEnteredAddTabButton := false.
       
  2479     tabWasActiveWhenPressed := false.
  2430 
  2480 
  2431     super initialize.
  2481     super initialize.
  2432 
  2482 
  2433     self enableMotionEvents.  "/ for flyByHelp
  2483     self enableMotionEvents.  "/ for flyByHelp
  2434     self cursor:Cursor hand.
  2484     self cursor:Cursor hand.
  2436     list             := #().
  2486     list             := #().
  2437     useIndex         := true.
  2487     useIndex         := true.
  2438     direction        := #top.
  2488     direction        := #top.
  2439     fitLastRow       := true.
  2489     fitLastRow       := true.
  2440     enabled          := true.
  2490     enabled          := true.
  2441     showDestroyTabButton := false.
       
  2442     canvasInset      := styleSheet at:#'noteBook.canvasInset'      default:1@1.
       
  2443     keepCanvas       := false.
       
  2444     tabLevel         := styleSheet at:#'noteBook.tabLevel'         default:1.
       
  2445     tabLabelInset    := styleSheet at:#'noteBook.tabLabelInset'    default:6@4.
       
  2446     selectionInsetX  := (2 max:(tabLevel abs)) + 1.
       
  2447     selectionInsetY  := (2 max:(tabLevel abs)) + 1.
       
  2448     translateLabel   := false.
       
  2449 
       
  2450     tabRightMargin   := 0.
       
  2451     tabLeftMargin    := 0.
       
  2452 
       
  2453     tabTopMargin    := styleSheet at:#'noteBook.tabTopMargin' default:4.
       
  2454     tabBottomMargin := styleSheet at:#'noteBook.tabBottomMargin' default:1.
       
  2455 
       
  2456     showingEnteredRemoveTabButton := showingEnteredAddTabButton := false.
       
  2457     tabWasActiveWhenPressed := false.
       
  2458 
  2491 
  2459     self lineWidth:0.
  2492     self lineWidth:0.
  2460 
  2493 
  2461 "/    canvas notNil ifTrue:[
  2494 "/    canvas notNil ifTrue:[
  2462 "/        canvas := canvas in:self.
  2495 "/        canvas := canvas in:self.