26 tabBottomMargin selectionInsetX selectionInsetY translateLabel |
26 tabBottomMargin selectionInsetX selectionInsetY translateLabel |
27 buttonPrev buttonNext tabRightMargin tabLeftMargin |
27 buttonPrev buttonNext tabRightMargin tabLeftMargin |
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 |
|
33 showingEnteredAddTabButton' |
32 classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
34 classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
33 DefaultActiveForegroundColor DefaultActiveBackgroundColor |
35 DefaultActiveForegroundColor DefaultActiveBackgroundColor |
34 DefaultShadowColor DefaultHalfShadowColor DefaultLightColor |
36 DefaultShadowColor DefaultHalfShadowColor DefaultLightColor |
35 DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor |
37 DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor |
36 DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor |
38 DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor |
37 RemoveTabIcon RemoveTabEnteredIcon' |
39 RemoveTabIcon RemoveTabEnteredIcon AddTabIcon AddTabEnteredIcon' |
38 poolDictionaries:'' |
40 poolDictionaries:'' |
39 category:'Views-Layout' |
41 category:'Views-Layout' |
40 ! |
42 ! |
41 |
43 |
42 Object subclass:#Tab |
44 Object subclass:#Tab |
93 tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
95 tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
94 top open. |
96 top open. |
95 [exEnd] |
97 [exEnd] |
96 |
98 |
97 |
99 |
98 tabs at left & right |
100 tabs at left & right |
99 [exBegin] |
101 [exBegin] |
100 |top tab1 tab2| |
102 |top tab1 tab2| |
101 |
103 |
102 top := StandardSystemView extent:100@300. |
104 top := StandardSystemView extent:100@300. |
103 tab1 := NoteBookView origin:0.0 @ 0.0 corner:0.5 @ 01.0 in:top. |
105 tab1 := NoteBookView origin:0.0 @ 0.0 corner:0.5 @ 01.0 in:top. |
104 tab1 direction:#left. |
106 tab1 direction:#left. |
105 tab1 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
107 tab1 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
106 |
108 |
107 tab2 := NoteBookView origin:0.5 @ 0.0 corner:1.0 @ 1.0 in:top. |
109 tab2 := NoteBookView origin:0.5 @ 0.0 corner:1.0 @ 1.0 in:top. |
|
110 tab2 direction:#right. |
|
111 tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
112 top open. |
|
113 [exEnd] |
|
114 |
|
115 tabs at top & bottom, with add-tab button |
|
116 [exBegin] |
|
117 |top tab1 tab2| |
|
118 |
|
119 top := StandardSystemView extent:300@100. |
|
120 tab1 := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top. |
|
121 tab1 addTabAction:[ self halt ]. |
|
122 tab1 direction:#top. |
|
123 tab1 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
124 |
|
125 tab2 := NoteBookView origin:0.0 @ 0.5 corner:1.0 @ 1.0 in:top. |
|
126 tab2 addTabAction:[ self halt ]. |
|
127 tab2 direction:#bottom. |
|
128 tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
129 top open. |
|
130 [exEnd] |
|
131 |
|
132 tabs at left & right, with add-tab button |
|
133 [exBegin] |
|
134 |top tab1 tab2| |
|
135 |
|
136 top := StandardSystemView extent:100@300. |
|
137 tab1 := NoteBookView origin:0.0 @ 0.0 corner:0.5 @ 01.0 in:top. |
|
138 tab1 addTabAction:[ self halt ]. |
|
139 tab1 direction:#left. |
|
140 tab1 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
141 |
|
142 tab2 := NoteBookView origin:0.5 @ 0.0 corner:1.0 @ 1.0 in:top. |
|
143 tab2 addTabAction:[ self halt ]. |
108 tab2 direction:#right. |
144 tab2 direction:#right. |
109 tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
145 tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
110 top open. |
146 top open. |
111 [exEnd] |
147 [exEnd] |
112 |
148 |
180 RemoveTabIcon := ToolbarIconLibrary removeTabIcon. |
216 RemoveTabIcon := ToolbarIconLibrary removeTabIcon. |
181 RemoveTabEnteredIcon := ToolbarIconLibrary removeTabEnteredIcon. |
217 RemoveTabEnteredIcon := ToolbarIconLibrary removeTabEnteredIcon. |
182 ] ifFalse:[ |
218 ] ifFalse:[ |
183 RemoveTabIcon := RemoveTabEnteredIcon := nil. |
219 RemoveTabIcon := RemoveTabEnteredIcon := nil. |
184 ]. |
220 ]. |
|
221 AddTabIcon := ToolbarIconLibrary addTabIcon. |
|
222 AddTabEnteredIcon := ToolbarIconLibrary addTabEnteredIcon. |
185 |
223 |
186 " |
224 " |
187 self updateStyleCache |
225 self updateStyleCache |
188 " |
226 " |
189 ! ! |
227 ! ! |
912 ] |
950 ] |
913 ! ! |
951 ! ! |
914 |
952 |
915 !NoteBookView methodsFor:'accessing-style'! |
953 !NoteBookView methodsFor:'accessing-style'! |
916 |
954 |
|
955 addTabAction:aBlockOrNil |
|
956 "if not nil, an add-tab button is shown beside the tab list, |
|
957 which calls aBlock" |
|
958 |
|
959 addTabAction := aBlockOrNil |
|
960 ! |
|
961 |
917 canvasInset |
962 canvasInset |
918 "inset of the canvas relative to my frame |
963 "inset of the canvas relative to my frame |
919 tabLevel + canvasInset == origin of canvas |
964 tabLevel + canvasInset == origin of canvas |
920 " |
965 " |
921 ^ canvasInset |
966 ^ canvasInset |
1302 ]. |
1347 ]. |
1303 ]. |
1348 ]. |
1304 ]. |
1349 ]. |
1305 ! |
1350 ! |
1306 |
1351 |
|
1352 drawAddTabButton |
|
1353 "redraw the add-tab button" |
|
1354 |
|
1355 |bFrame icon| |
|
1356 |
|
1357 bFrame := self frameForAddTabButton. |
|
1358 |
|
1359 self paint:(showingEnteredAddTabButton ifTrue:[Color green]ifFalse:[Color red]). |
|
1360 self fillRectangle:bFrame. |
|
1361 self paint:Color black. |
|
1362 |
|
1363 AddTabIcon notNil ifTrue:[ |
|
1364 addTabIcon isNil ifTrue:[ |
|
1365 addTabIcon := AddTabIcon onDevice:(self device). |
|
1366 addTabEnteredIcon := AddTabEnteredIcon onDevice:(self device). |
|
1367 ]. |
|
1368 showingEnteredAddTabButton |
|
1369 ifTrue:[icon := addTabEnteredIcon] |
|
1370 ifFalse:[icon := addTabIcon]. |
|
1371 icon displayOn:self at:bFrame origin. |
|
1372 ] ifFalse:[ |
|
1373 self displayRectangle:bFrame. |
|
1374 self displayLineFrom:bFrame leftCenter+(1@0) to:bFrame rightCenter-(1@0). |
|
1375 self displayLineFrom:bFrame topCenter+(0@1) to:bFrame bottomCenter-(0@1). |
|
1376 ] |
|
1377 ! |
|
1378 |
1307 drawBorderEdges |
1379 drawBorderEdges |
1308 |layout x0 x1 y0 y1 trans| |
1380 |layout x0 x1 y0 y1 trans| |
1309 |
1381 |
1310 "/ test whether TabView and not NoteBookView |
1382 "/ test whether TabView and not NoteBookView |
1311 tabModus ifTrue:[^ self]. |
1383 tabModus ifTrue:[^ self]. |
1680 (line := selectedTab lineNr) ~~ 1 ifTrue:[ |
1752 (line := selectedTab lineNr) ~~ 1 ifTrue:[ |
1681 self makeToBaseLine:line. |
1753 self makeToBaseLine:line. |
1682 ^ self |
1754 ^ self |
1683 ] |
1755 ] |
1684 ]. |
1756 ]. |
|
1757 |
1685 damage := Rectangle left:x top:y width:w height:h. |
1758 damage := Rectangle left:x top:y width:w height:h. |
1686 |
1759 |
1687 "/ draw the damage intersects the tabs with my superViews background |
1760 "/ draw the damage intersects the tabs with my superViews background |
1688 borderLayout := self computeBorderLayout. |
1761 borderLayout := self computeBorderLayout. |
1689 |
1762 |
1695 (damage areasOutside:borderLayout) do:[:r| |
1768 (damage areasOutside:borderLayout) do:[:r| |
1696 self paint:(superView viewBackground). |
1769 self paint:(superView viewBackground). |
1697 self fillRectangle:r. |
1770 self fillRectangle:r. |
1698 ]. |
1771 ]. |
1699 |
1772 |
|
1773 addTabAction notNil ifTrue:[ |
|
1774 (damage intersects:(self frameForAddTabButton)) ifTrue:[ |
|
1775 self drawAddTabButton |
|
1776 ]. |
|
1777 ]. |
1700 "/ OLD CODE |
1778 "/ OLD CODE |
1701 "/ myRectangle := Rectangle origin:0@0 extent:self extent. |
1779 "/ myRectangle := Rectangle origin:0@0 extent:self extent. |
1702 "/ |
1780 "/ |
1703 "/ (myRectangle areasOutside:borderLayout) do:[:r| |
1781 "/ (myRectangle areasOutside:borderLayout) do:[:r| |
1704 "/ (r intersects:damage) ifTrue:[ |
1782 "/ (r intersects:damage) ifTrue:[ |
1749 ! ! |
1827 ! ! |
1750 |
1828 |
1751 !NoteBookView methodsFor:'event handling'! |
1829 !NoteBookView methodsFor:'event handling'! |
1752 |
1830 |
1753 buttonMotion:buttonState x:x y:y |
1831 buttonMotion:buttonState x:x y:y |
1754 |tab mustShowEntered| |
1832 |tab mustShowEntered newEntered| |
1755 |
1833 |
1756 "/ if we have to show a different icon while over the tab... |
1834 "/ if we have to show a different icon while over the tab... |
1757 tab := self tabContainingPointX:x y:y. |
1835 tab := self tabContainingPointX:x y:y. |
1758 (tab notNil and:[tab == self selectedTab]) ifTrue:[ |
1836 (tab notNil and:[tab == self selectedTab]) ifTrue:[ |
1759 (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
1837 (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
1763 self drawDestroyButtonForTab:tab. |
1841 self drawDestroyButtonForTab:tab. |
1764 ] |
1842 ] |
1765 ]. |
1843 ]. |
1766 ]. |
1844 ]. |
1767 |
1845 |
|
1846 addTabAction notNil ifTrue:[ |
|
1847 newEntered := self frameForAddTabButton containsPoint:(x@y). |
|
1848 (newEntered ~= showingEnteredAddTabButton) ifTrue:[ |
|
1849 showingEnteredAddTabButton := newEntered. |
|
1850 self drawAddTabButton. |
|
1851 ]. |
|
1852 ]. |
|
1853 |
1768 super buttonMotion:buttonState x:x y:y |
1854 super buttonMotion:buttonState x:x y:y |
1769 |
1855 |
1770 "Modified: / 01-03-2007 / 17:07:41 / cg" |
1856 "Modified: / 01-03-2007 / 17:07:41 / cg" |
1771 ! |
1857 ! |
1772 |
1858 |
1824 |
1910 |
1825 enabled ifFalse:[ ^ self ]. |
1911 enabled ifFalse:[ ^ self ]. |
1826 list isEmpty ifTrue:[ ^ self ]. |
1912 list isEmpty ifTrue:[ ^ self ]. |
1827 |
1913 |
1828 isDestroyAction := false. |
1914 isDestroyAction := false. |
|
1915 |
|
1916 addTabAction notNil ifTrue:[ |
|
1917 (self frameForAddTabButton containsPoint:(x@y)) ifTrue:[ |
|
1918 addTabAction value. |
|
1919 ^ self. |
|
1920 ]. |
|
1921 ]. |
1829 |
1922 |
1830 tabWasActiveWhenPressed ifTrue:[ |
1923 tabWasActiveWhenPressed ifTrue:[ |
1831 idx := list findFirst:[:aTab| |
1924 idx := list findFirst:[:aTab| |
1832 (self isDestroyTabButtonShownFor:aTab) |
1925 (self isDestroyTabButtonShownFor:aTab) |
1833 and:[ aTab containsPointX:x y:y ] |
1926 and:[ aTab containsPointX:x y:y ] |
1898 tab := self selectedTab. |
1991 tab := self selectedTab. |
1899 tab notNil ifTrue:[ |
1992 tab notNil ifTrue:[ |
1900 self drawDestroyButtonForTab:tab. |
1993 self drawDestroyButtonForTab:tab. |
1901 ] |
1994 ] |
1902 ]. |
1995 ]. |
|
1996 addTabAction notNil ifTrue:[ |
|
1997 showingEnteredAddTabButton ifTrue:[ |
|
1998 showingEnteredRemoveTabButton := false. |
|
1999 self drawAddTabButton. |
|
2000 ]. |
|
2001 ]. |
1903 super pointerLeave:state |
2002 super pointerLeave:state |
1904 ! |
2003 ! |
1905 |
2004 |
1906 processAccessCharacter:aKey |
2005 processAccessCharacter:aKey |
1907 "a character is pressed; check for tab identified by the character |
2006 "a character is pressed; check for tab identified by the character |
2352 tabLeftMargin := 0. |
2451 tabLeftMargin := 0. |
2353 |
2452 |
2354 tabTopMargin := styleSheet at:#'noteBook.tabTopMargin' default:4. |
2453 tabTopMargin := styleSheet at:#'noteBook.tabTopMargin' default:4. |
2355 tabBottomMargin := styleSheet at:#'noteBook.tabBottomMargin' default:1. |
2454 tabBottomMargin := styleSheet at:#'noteBook.tabBottomMargin' default:1. |
2356 |
2455 |
2357 showingEnteredRemoveTabButton := false. |
2456 showingEnteredRemoveTabButton := showingEnteredAddTabButton := false. |
2358 tabWasActiveWhenPressed := false. |
2457 tabWasActiveWhenPressed := false. |
2359 |
2458 |
2360 self lineWidth:0. |
2459 self lineWidth:0. |
2361 |
2460 |
2362 "/ canvas notNil ifTrue:[ |
2461 "/ canvas notNil ifTrue:[ |
2487 ] |
2586 ] |
2488 ]. |
2587 ]. |
2489 computedLayout := Rectangle left:tabLeft top:tabTop right:tabRight bottom:tabBottom. |
2588 computedLayout := Rectangle left:tabLeft top:tabTop right:tabRight bottom:tabBottom. |
2490 aTab selectedLayout:computedLayout. |
2589 aTab selectedLayout:computedLayout. |
2491 ^ computedLayout |
2590 ^ computedLayout |
|
2591 ! |
|
2592 |
|
2593 frameForAddTabButton |
|
2594 |firstTab w h m frameHeight frameWidth| |
|
2595 |
|
2596 list isEmptyOrNil ifTrue:[^ nil]. |
|
2597 |
|
2598 m := 2. |
|
2599 |
|
2600 w := h := 16. |
|
2601 addTabIcon notNil ifTrue:[ |
|
2602 w := addTabIcon width. |
|
2603 h := addTabIcon height |
|
2604 ]. |
|
2605 |
|
2606 firstTab := list first unselectedLayout. |
|
2607 |
|
2608 self isHorizontal ifTrue:[ |
|
2609 frameHeight := firstTab height. |
|
2610 direction == #top ifTrue:[ |
|
2611 ^ Rectangle origin:( (width-w-m) @ (frameHeight-h)) |
|
2612 extent:( w @ h ) |
|
2613 ]. |
|
2614 "/ bottom |
|
2615 ^ Rectangle origin:( (width-w-m) @ (height-frameHeight)) |
|
2616 extent:( w @ h) |
|
2617 ] ifFalse:[ |
|
2618 frameWidth := firstTab width. |
|
2619 direction == #right ifTrue:[ |
|
2620 ^ Rectangle origin:( (width-w-m) @ (height-20)) |
|
2621 extent:( w @ h) |
|
2622 ]. |
|
2623 "/ left |
|
2624 ^ Rectangle origin:( m @ (height-20)) |
|
2625 extent:( w @ h) |
|
2626 ]. |
2492 ! |
2627 ! |
2493 |
2628 |
2494 makeToBaseLine:aLnNr |
2629 makeToBaseLine:aLnNr |
2495 "rotate lines to make the line #aLnNr be the new base line (i.e. |
2630 "rotate lines to make the line #aLnNr be the new base line (i.e. |
2496 subtract (aLnNr-1) from all lines and take modulu the number of lines" |
2631 subtract (aLnNr-1) from all lines and take modulu the number of lines" |
2597 tabHeight := 0. |
2732 tabHeight := 0. |
2598 leftMargin := self tabLeftMargin. |
2733 leftMargin := self tabLeftMargin. |
2599 rightMargin := self tabRightMargin. |
2734 rightMargin := self tabRightMargin. |
2600 minLeft := leftMargin + selectionInsetX. |
2735 minLeft := leftMargin + selectionInsetX. |
2601 maxRight := self width - rightMargin - selectionInsetX. |
2736 maxRight := self width - rightMargin - selectionInsetX. |
|
2737 addTabAction notNil ifTrue:[ |
|
2738 maxRight := maxRight - self horizontalMarginForAddTabButton |
|
2739 ]. |
2602 xLeft := minLeft. |
2740 xLeft := minLeft. |
2603 isScrollable := self hasScrollButtons. |
2741 isScrollable := self hasScrollButtons. |
2604 |
2742 |
2605 list do:[:aTab| |
2743 list do:[:aTab| |
2606 tabExtent := self preferredExtentForTab:aTab. |
2744 tabExtent := self preferredExtentForTab:aTab. |
2726 tabHeight := 0. |
2864 tabHeight := 0. |
2727 leftMargin := self tabLeftMargin. |
2865 leftMargin := self tabLeftMargin. |
2728 rightMargin := self tabRightMargin. |
2866 rightMargin := self tabRightMargin. |
2729 minTop := leftMargin + selectionInsetX. |
2867 minTop := leftMargin + selectionInsetX. |
2730 maxBottom := self height - rightMargin - selectionInsetX. |
2868 maxBottom := self height - rightMargin - selectionInsetX. |
|
2869 addTabAction notNil ifTrue:[ |
|
2870 maxBottom := maxBottom - self verticalMarginForAddTabButton |
|
2871 ]. |
2731 yTop := minTop. |
2872 yTop := minTop. |
2732 isScrollable := self hasScrollButtons. |
2873 isScrollable := self hasScrollButtons. |
2733 |
2874 |
2734 list do:[:aTab| aTab layout:nil; unselectedLayout:nil; selectedLayout:nil]. |
2875 list do:[:aTab| aTab layout:nil; unselectedLayout:nil; selectedLayout:nil]. |
2735 |
2876 |
2900 self listHolder:aValueHolder. |
3041 self listHolder:aValueHolder. |
2901 ! ! |
3042 ! ! |
2902 |
3043 |
2903 !NoteBookView methodsFor:'private'! |
3044 !NoteBookView methodsFor:'private'! |
2904 |
3045 |
|
3046 horizontalMarginForAddTabButton |
|
3047 "should be changed to be style specific; |
|
3048 some (win8) prefer an additional, empty short tab" |
|
3049 |
|
3050 ^ 20 |
|
3051 ! |
|
3052 |
2905 indexOfTab:aTab |
3053 indexOfTab:aTab |
2906 ^ list indexOf:aTab |
3054 ^ list indexOf:aTab |
2907 ! |
3055 ! |
2908 |
3056 |
2909 tabContainingPointX:x y:y |
3057 tabContainingPointX:x y:y |
2910 ^ list detect:[:aTab| aTab containsPointX:x y:y ] ifNone:nil. |
3058 ^ list detect:[:aTab| aTab containsPointX:x y:y ] ifNone:nil. |
|
3059 ! |
|
3060 |
|
3061 verticalMarginForAddTabButton |
|
3062 "should be changed to be style specific; |
|
3063 some (win8) prefer an additional, empty short tab" |
|
3064 |
|
3065 ^ 20 |
2911 ! ! |
3066 ! ! |
2912 |
3067 |
2913 !NoteBookView methodsFor:'private-buttons'! |
3068 !NoteBookView methodsFor:'private-buttons'! |
2914 |
3069 |
2915 buttonLayoutUpdate |
3070 buttonLayoutUpdate |