NoteBookView.st
changeset 5217 034b6149d8bc
parent 5211 d4a5b7bf3021
child 5218 4999a9f57b7d
equal deleted inserted replaced
5216:50b4b75edc7b 5217:034b6149d8bc
    26 		showDestroyTabButton destroyTabAction activeTabMarkerColor
    26 		showDestroyTabButton destroyTabAction activeTabMarkerColor
    27 		activeTabMarkerFGColor tabWasActiveWhenPressed removeTabIcon
    27 		activeTabMarkerFGColor tabWasActiveWhenPressed removeTabIcon
    28 		removeTabEnteredIcon removeTabDisabledIcon
    28 		removeTabEnteredIcon removeTabDisabledIcon
    29 		showingEnteredRemoveTabButton lastUserSelection minimumTabWidth
    29 		showingEnteredRemoveTabButton lastUserSelection minimumTabWidth
    30 		addTabAction addTabIcon addTabEnteredIcon addTabDisabledIcon
    30 		addTabAction addTabIcon addTabEnteredIcon addTabDisabledIcon
    31 		showingEnteredAddTabButton canvasLevel'
    31 		showingEnteredAddTabButton canvasLevel
       
    32 		showDestroyTabButtonOnSingleTab'
    32 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    33 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    33 		DefaultActiveForegroundColor DefaultActiveBackgroundColor
    34 		DefaultActiveForegroundColor DefaultActiveBackgroundColor
    34 		DefaultShadowColor DefaultHalfShadowColor DefaultLightColor
    35 		DefaultShadowColor DefaultHalfShadowColor DefaultLightColor
    35 		DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor
    36 		DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor
    36 		DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor
    37 		DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor
   372     ^ list collect:[:aTab| aTab label ]
   373     ^ list collect:[:aTab| aTab label ]
   373 
   374 
   374 !
   375 !
   375 
   376 
   376 list:newTabItemListOrNil
   377 list:newTabItemListOrNil
   377     "set the tab-list"
   378     "set the tab-list.
       
   379      warning: transforms the given list to a list of tabItems,
       
   380      where each holds on to a corresponding list element.
       
   381      When a new list comes in, the list elements are compared for identity.
       
   382      This may make problems, when strings come in.
       
   383      Q: should we compare for equality here?"
   378 
   384 
   379     |selectionName newList newTabItemList oldSelectedTab|
   385     |selectionName newList newTabItemList oldSelectedTab|
   380 
   386 
   381     newTabItemList := newTabItemListOrNil ? #().
   387     newTabItemList := newTabItemListOrNil ? #().
   382 
   388 
   892     minimumTabWidth notNil ifTrue:[
   898     minimumTabWidth notNil ifTrue:[
   893         tabExtent := Point x:(tabExtent x max:minimumTabWidth) y:(tabExtent y).
   899         tabExtent := Point x:(tabExtent x max:minimumTabWidth) y:(tabExtent y).
   894     ].
   900     ].
   895     tabExtent := tabExtent + tabLabelInset.
   901     tabExtent := tabExtent + tabLabelInset.
   896 
   902 
   897     (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[
   903     (self showingDestroyButton) ifTrue:[
   898         tabExtent := tabExtent + ((self destroyButtonUsedWidth) @ 0).
   904         tabExtent := tabExtent + ((self destroyButtonUsedWidth) @ 0).
   899     ].
   905     ].
   900     ^ tabExtent.
   906     ^ tabExtent.
   901 ! !
   907 ! !
   902 
   908 
  1071         self styleChanged.
  1077         self styleChanged.
  1072     ].
  1078     ].
  1073 !
  1079 !
  1074 
  1080 
  1075 showDestroyTabButton
  1081 showDestroyTabButton
       
  1082     "if true, a close-tab icon is shown"
       
  1083 
  1076     ^ showDestroyTabButton
  1084     ^ showDestroyTabButton
  1077 !
  1085 !
  1078 
  1086 
  1079 showDestroyTabButton:aBoolean
  1087 showDestroyTabButton:aBoolean
       
  1088     "if true, a close-tab icon is shown"
       
  1089 
  1080     showDestroyTabButton == aBoolean ifTrue:[^ self].
  1090     showDestroyTabButton == aBoolean ifTrue:[^ self].
  1081     showDestroyTabButton := aBoolean.
  1091     showDestroyTabButton := aBoolean.
       
  1092 
       
  1093     self styleChanged.
       
  1094 !
       
  1095 
       
  1096 showDestroyTabButtonOnSingleTab
       
  1097     "if true, AND showDestroyTabButton is true,
       
  1098      a close-tab icon is shown even for a single tab.
       
  1099      Otherwise, it is hidden if there is only one tab-item left"
       
  1100 
       
  1101     ^ showDestroyTabButtonOnSingleTab
       
  1102 !
       
  1103 
       
  1104 showDestroyTabButtonOnSingleTab:aBoolean
       
  1105     "if true, AND showDestroyTabButton is true,
       
  1106      a close-tab icon is shown even for a single tab.
       
  1107      Otherwise, it is hidden if there is only one tab-item left"
       
  1108 
       
  1109     showDestroyTabButtonOnSingleTab == aBoolean ifTrue:[^ self].
       
  1110     showDestroyTabButtonOnSingleTab := aBoolean.
  1082 
  1111 
  1083     self styleChanged.
  1112     self styleChanged.
  1084 !
  1113 !
  1085 
  1114 
  1086 tabBottomMargin
  1115 tabBottomMargin
  1841     |tab mustShowEntered newEntered|
  1870     |tab mustShowEntered newEntered|
  1842 
  1871 
  1843     "/ if we have to show a different icon while over the tab...
  1872     "/ if we have to show a different icon while over the tab...
  1844     tab := self tabContainingPointX:x y:y.
  1873     tab := self tabContainingPointX:x y:y.
  1845     (tab notNil and:[tab == self selectedTab]) ifTrue:[
  1874     (tab notNil and:[tab == self selectedTab]) ifTrue:[
  1846         (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[
  1875         (self showingDestroyButton) ifTrue:[
  1847             mustShowEntered := (self destroyButtonFrameForTab:tab) containsPoint:(x@y).
  1876             mustShowEntered := (self destroyButtonFrameForTab:tab) containsPoint:(x@y).
  1848             mustShowEntered ~~ showingEnteredRemoveTabButton ifTrue:[
  1877             mustShowEntered ~~ showingEnteredRemoveTabButton ifTrue:[
  1849                 showingEnteredRemoveTabButton := mustShowEntered.
  1878                 showingEnteredRemoveTabButton := mustShowEntered.
  1850                 self drawDestroyButtonForTab:tab.    
  1879                 self drawDestroyButtonForTab:tab.    
  1851             ]
  1880             ]
  2291     x := srcPoint x.
  2320     x := srcPoint x.
  2292     y := srcPoint y.
  2321     y := srcPoint y.
  2293     tab := self tabContainingPointX:x y:y.
  2322     tab := self tabContainingPointX:x y:y.
  2294 
  2323 
  2295     tab notNil ifTrue:[
  2324     tab notNil ifTrue:[
  2296         (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[
  2325         (self showingDestroyButton) ifTrue:[
  2297             (tab == self selectedTab
  2326             (tab == self selectedTab
  2298             or:[ self disableDestroyButtonOfInactiveTabs not ]) ifTrue:[
  2327             or:[ self disableDestroyButtonOfInactiveTabs not ]) ifTrue:[
  2299                 ((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[
  2328                 ((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[
  2300                     ^ resources string:'Remove this Tab'
  2329                     ^ resources string:'Remove this Tab'
  2301                 ]
  2330                 ]
  3344 isDestroyTabButtonShownFor:aTab
  3373 isDestroyTabButtonShownFor:aTab
  3345     "returns true if the destroyButton for a tab is shown"
  3374     "returns true if the destroyButton for a tab is shown"
  3346 
  3375 
  3347     aTab destroyTabButtonShown ifTrue:[^ true].
  3376     aTab destroyTabButtonShown ifTrue:[^ true].
  3348 
  3377 
  3349     (showDestroyTabButton and:[destroyTabAction notNil]) ifFalse:[
  3378     (self showingDestroyButton) ifFalse:[
  3350         ^ false
  3379         ^ false
  3351     ].
  3380     ].
  3352     self showDestroyButtonOfInactiveTabs ifTrue:[^ true].
  3381     self showDestroyButtonOfInactiveTabs ifTrue:[^ true].
  3353     ^ self selectedTab == aTab
  3382     ^ self selectedTab == aTab
  3354 !
  3383 !
  3373 
  3402 
  3374     index   := list identityIndexOf:aTab.
  3403     index   := list identityIndexOf:aTab.
  3375     nextTab := list at:(index + 1) ifAbsent:nil.
  3404     nextTab := list at:(index + 1) ifAbsent:nil.
  3376 
  3405 
  3377   ^ nextTab isNil or:[nextTab lineNr ~~ aTab lineNr]
  3406   ^ nextTab isNil or:[nextTab lineNr ~~ aTab lineNr]
       
  3407 !
       
  3408 
       
  3409 showingDestroyButton
       
  3410      ^ showDestroyTabButton 
       
  3411      and:[destroyTabAction notNil
       
  3412      and:[(showDestroyTabButtonOnSingleTab ~~ true) or:[list size > 1]]]
  3378 ! !
  3413 ! !
  3379 
  3414 
  3380 !NoteBookView methodsFor:'selection'!
  3415 !NoteBookView methodsFor:'selection'!
  3381 
  3416 
  3382 isSelectable:anIndex
  3417 isSelectable:anIndex