author | Stefan Vogel <sv@exept.de> |
Fri, 01 Aug 2008 18:33:52 +0200 | |
changeset 3517 | 28e67762acd0 |
parent 3515 | b1607d939ae8 |
child 3520 | 95e9f33ec533 |
permissions | -rw-r--r-- |
375 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1401 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1759 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
1401 | 14 |
View subclass:#NoteBookView |
2760 | 15 |
instanceVariableNames:'list listHolder foregroundColor backgroundColor selection enabled |
16 |
action useIndex direction numberOfLines selectConditionBlock |
|
17 |
accessTabMenuAction canvas canvasInset canvasHolder |
|
18 |
halfLightColor halfShadowColor fitLastRow tabModus |
|
19 |
lastComputedExtent keepCanvas activeForegroundColor |
|
20 |
activeBackgroundColor drawLightColor edgeStyle tabInset |
|
2431 | 21 |
tabLabelInset disabledForegroundColor tabLevel tabTopMargin |
2686 | 22 |
tabBottomMargin selectionInsetX selectionInsetY translateLabel |
2875 | 23 |
buttonPrev buttonNext tabRightMargin tabLeftMargin |
2882 | 24 |
showDestroyTabButton destroyTabAction activeTabMarkerColor |
3180 | 25 |
activeTabMarkerFGColor tabWasActiveWhenPressed removeTabIcon |
3181 | 26 |
removeTabEnteredIcon removeTabDisabledIcon |
3336
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
27 |
showingEnteredRemoveTabButton lastUserSelection' |
2760 | 28 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
29 |
DefaultActiveForegroundColor DefaultActiveBackgroundColor |
|
1682 | 30 |
DefaultShadowColor DefaultHalfShadowColor DefaultLightColor |
2758 | 31 |
DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor |
3180 | 32 |
DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor |
33 |
RemoveTabIcon RemoveTabEnteredIcon' |
|
1401 | 34 |
poolDictionaries:'' |
35 |
category:'Views-Layout' |
|
36 |
! |
|
37 |
||
38 |
Object subclass:#Tab |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
39 |
instanceVariableNames:'label tabItem printableLabel disabledLabel lineNr |
3207 | 40 |
unselectedLayout selectedLayout layout extent accessCharacter |
41 |
lastFocusViewId' |
|
1401 | 42 |
classVariableNames:'' |
43 |
poolDictionaries:'' |
|
44 |
privateIn:NoteBookView |
|
45 |
! |
|
46 |
||
47 |
!NoteBookView class methodsFor:'documentation'! |
|
48 |
||
49 |
copyright |
|
50 |
" |
|
51 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
52 |
All Rights Reserved |
|
375 | 53 |
|
54 |
This software is furnished under a license and may be used |
|
55 |
only in accordance with the terms of that license and with the |
|
56 |
inclusion of the above copyright notice. This software may not |
|
57 |
be provided or otherwise made available to, or used by, any |
|
58 |
other person. No title to or ownership of the software is |
|
59 |
hereby transferred. |
|
60 |
" |
|
61 |
||
355 | 62 |
! |
63 |
||
64 |
documentation |
|
65 |
" |
|
1401 | 66 |
implements the noteBook. |
67 |
||
68 |
[author:] |
|
69 |
Claus Atzkern |
|
408 | 70 |
|
71 |
[see also:] |
|
72 |
TabView |
|
355 | 73 |
" |
408 | 74 |
! |
355 | 75 |
|
408 | 76 |
examples |
77 |
" |
|
3186 | 78 |
tabs at top & bottom |
408 | 79 |
[exBegin] |
3186 | 80 |
|top tab1 tab2| |
81 |
||
82 |
top := StandardSystemView extent:300@100. |
|
83 |
tab1 := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top. |
|
84 |
tab1 direction:#top. |
|
85 |
tab1 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
86 |
||
87 |
tab2 := NoteBookView origin:0.0 @ 0.5 corner:1.0 @ 1.0 in:top. |
|
88 |
tab2 direction:#bottom. |
|
89 |
tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
375 | 90 |
top open. |
408 | 91 |
[exEnd] |
375 | 92 |
|
3186 | 93 |
|
94 |
tabs at left & right |
|
408 | 95 |
[exBegin] |
3186 | 96 |
|top tab1 tab2| |
97 |
||
98 |
top := StandardSystemView extent:100@300. |
|
99 |
tab1 := NoteBookView origin:0.0 @ 0.0 corner:0.5 @ 01.0 in:top. |
|
100 |
tab1 direction:#left. |
|
101 |
tab1 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
102 |
||
103 |
tab2 := NoteBookView origin:0.5 @ 0.0 corner:1.0 @ 1.0 in:top. |
|
104 |
tab2 direction:#right. |
|
105 |
tab2 list:#( 'Foo' 'Bagr' 'Baz' 'Bgar' 'Baqz' ). |
|
408 | 106 |
top open. |
107 |
[exEnd] |
|
375 | 108 |
|
408 | 109 |
" |
1401 | 110 |
! ! |
111 |
||
112 |
!NoteBookView class methodsFor:'defaults'! |
|
113 |
||
114 |
defaultFont |
|
115 |
^ MenuView defaultFont |
|
1682 | 116 |
! |
117 |
||
118 |
updateStyleCache |
|
2777 | 119 |
"extract values from the styleSheet and cache them in class variables" |
120 |
||
121 |
<resource: #style (#'noteBook.foregroundColor' #'noteBook.backgroundColor' |
|
122 |
#'noteBook.activeForegroundColor' #'noteBook.activeBackgroundColor' |
|
123 |
#'noteBook.lightColor' #'noteBook.halfLightColor' #'noteBook.shadowColor' |
|
124 |
#'noteBook.halfShadowColor' #'noteBook.edgeStyle' |
|
125 |
#'noteBook.activeTabMarkerColor' |
|
3180 | 126 |
#'noteBook.showRemoveTabIcon' |
2777 | 127 |
)> |
128 |
||
1682 | 129 |
DefaultForegroundColor := StyleSheet colorAt:#'noteBook.foregroundColor'. |
130 |
DefaultForegroundColor isNil ifTrue:[ |
|
131 |
DefaultForegroundColor := StyleSheet colorAt:#'button.foregroundColor'. |
|
132 |
]. |
|
2760 | 133 |
DefaultBackgroundColor := StyleSheet colorAt:#'noteBook.backgroundColor'. |
1682 | 134 |
|
135 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'noteBook.activeForegroundColor'. |
|
136 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
137 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'button.activeForegroundColor' |
|
138 |
]. |
|
2760 | 139 |
DefaultActiveBackgroundColor := StyleSheet colorAt:#'noteBook.activeBackgroundColor'. |
1682 | 140 |
|
141 |
DefaultLightColor := StyleSheet colorAt:#'noteBook.lightColor'. |
|
142 |
DefaultLightColor isNil ifTrue:[ |
|
143 |
DefaultLightColor := StyleSheet colorAt:'button.lightColor' |
|
144 |
]. |
|
145 |
DefaultHalfLightColor := StyleSheet colorAt:#'noteBook.halfLightColor'. |
|
146 |
DefaultHalfLightColor isNil ifTrue:[ |
|
147 |
DefaultHalfLightColor := StyleSheet colorAt:#'button.halfLightColor' |
|
148 |
]. |
|
149 |
||
150 |
DefaultShadowColor := StyleSheet colorAt:#'noteBook.shadowColor'. |
|
151 |
DefaultShadowColor isNil ifTrue:[ |
|
152 |
DefaultShadowColor := StyleSheet colorAt:'button.shadowColor' |
|
153 |
]. |
|
154 |
DefaultHalfShadowColor := StyleSheet colorAt:#'noteBook.halfShadowColor'. |
|
155 |
DefaultHalfShadowColor isNil ifTrue:[ |
|
156 |
DefaultHalfShadowColor := StyleSheet colorAt:#'button.halfShadowColor' |
|
157 |
]. |
|
158 |
DefaultEdgeStyle := StyleSheet at:#'noteBook.edgeStyle'. |
|
159 |
DefaultEdgeStyle isNil ifTrue:[ |
|
160 |
DefaultEdgeStyle := StyleSheet at:#'button.edgeStyle' |
|
161 |
]. |
|
162 |
||
1683 | 163 |
DefaultEdgeStyle == #softWin95 ifFalse:[ |
1682 | 164 |
DefaultEdgeStyle := nil |
165 |
]. |
|
166 |
||
2758 | 167 |
DefaultActiveTabMarkerColor := StyleSheet colorAt:#'noteBook.activeTabMarkerColor'. |
2763 | 168 |
DefaultActiveTabMarkerColor isNil ifTrue:[ |
169 |
DefaultActiveTabMarkerFgColor := nil. |
|
170 |
] ifFalse:[ |
|
171 |
DefaultActiveTabMarkerFgColor := Color redByte:255 greenByte:138 blueByte:41. |
|
172 |
]. |
|
2777 | 173 |
|
3180 | 174 |
(StyleSheet at:#'noteBook.showRemoveTabIcon' default:true) ifTrue:[ |
3343
59113bee857a
do NOT (I repeat NOT) access XPToolbarIconLibrary directly.
Claus Gittinger <cg@exept.de>
parents:
3336
diff
changeset
|
175 |
RemoveTabIcon := ToolbarIconLibrary removeTabIcon. |
3353
f171a66e2b25
fixed to work under non-XP styles
Claus Gittinger <cg@exept.de>
parents:
3343
diff
changeset
|
176 |
RemoveTabEnteredIcon := ToolbarIconLibrary removeTabEnteredIcon. |
3180 | 177 |
] ifFalse:[ |
178 |
RemoveTabIcon := RemoveTabEnteredIcon := nil. |
|
179 |
]. |
|
180 |
||
2777 | 181 |
" |
182 |
self updateStyleCache |
|
183 |
" |
|
375 | 184 |
! ! |
185 |
||
3180 | 186 |
!NoteBookView class methodsFor:'image specs'! |
187 |
||
188 |
tabBackgroundVista |
|
189 |
"This resource specification was automatically generated |
|
190 |
by the ImageEditor of ST/X." |
|
191 |
||
192 |
"Do not manually edit this!! If it is corrupted, |
|
193 |
the ImageEditor may not be able to read the specification." |
|
194 |
||
195 |
" |
|
196 |
self tabBackgroundVista inspect |
|
197 |
ImageEditor openOnClass:self andSelector:#tabBackgroundVista |
|
198 |
Icon flushCachedIcons |
|
199 |
" |
|
200 |
||
201 |
<resource: #image> |
|
202 |
||
203 |
^Icon |
|
204 |
constantNamed:#'NoteBookView class tabBackgroundVista' |
|
205 |
ifAbsentPut:[(Depth8Image new) width: 5; height: 25; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
206 |
B@ HB@ NC 8NC 4MCP4MCP4MCP4LC@0LC@,KB0,KB0,KB0,JB (JB (JB (JBP$IBP$GA0\GA0@@@@@@@@@@@@@@@@@@@@@@@@@@@PDA@PDA@PDA@PHB@ HB |
|
207 |
@0LC@0LDA@PDA@TEAPTEA XFA XGA0\GA0\GA0\GA0\GA0\b') ; colorMapFromArray:#[232 232 232 233 233 233 234 234 234 235 235 235 236 236 236 237 237 237 238 238 238 240 240 240 242 242 242 245 245 245 246 246 246 247 247 247 248 248 248 249 249 249 250 250 250]; yourself] |
|
208 |
! ! |
|
209 |
||
2496 | 210 |
!NoteBookView methodsFor:'accepting-items'! |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
211 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
212 |
tabAtIndex:tabIndex put:newLabelOrTabItem |
2691 | 213 |
"called if the contents of a tab changed; test whether the old layout can |
214 |
be reused otherwise we must recompute the whole list |
|
215 |
" |
|
3432 | 216 |
|tab tabLayout prefX prefY tabPrefExtent| |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
217 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
218 |
"/ a single items label has changed |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
219 |
tab := list at:tabIndex ifAbsent:nil. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
220 |
tab notNil ifTrue:[ |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
221 |
tab labelOrTabItem:newLabelOrTabItem on:self. |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
222 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
223 |
"/ no resizing, if the new string fits |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
224 |
"/ and is not too small for current tab-layout |
2896 | 225 |
tabLayout := tab unselectedLayout. |
3432 | 226 |
tabPrefExtent := self preferredExtentForTab:tab. |
227 |
prefX := tabPrefExtent x. |
|
228 |
prefY := tabPrefExtent y. |
|
229 |
||
3433 | 230 |
(prefX <= tabLayout width and:[prefY <= tabLayout height]) ifTrue:[ |
3432 | 231 |
"/ the new string fits into the current tab-layout |
1880 | 232 |
|
233 |
numberOfLines == 1 ifTrue:[ "/ do not change the layout |
|
234 |
^ self invalidateTab:tab |
|
235 |
]. |
|
236 |
||
237 |
"/ check whether the string is not too small for current tab-layout |
|
2896 | 238 |
((tabLayout width <= (prefX * 1.5)) and:[tabLayout height <= (prefY * 1.5)]) ifTrue:[ |
1880 | 239 |
^ self invalidateTab:tab. "/ do not change the layout |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
240 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
241 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
242 |
self recomputeList. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
243 |
self invalidate. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
244 |
^ self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
245 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
246 |
"/ can this happen ? |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
247 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
248 |
"Created: / 25-02-2000 / 14:13:59 / cg" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
249 |
"Modified: / 06-09-2006 / 17:17:03 / cg" |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
250 |
! ! |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
251 |
|
375 | 252 |
!NoteBookView methodsFor:'accessing'! |
355 | 253 |
|
375 | 254 |
canvas |
2691 | 255 |
"returns the canvas; the containter view |
256 |
" |
|
375 | 257 |
^ canvas |
258 |
! |
|
259 |
||
2492 | 260 |
canvas:newCanvas |
3193
92cab090c80d
replace obsolete method invocation
Stefan Vogel <sv@exept.de>
parents:
3190
diff
changeset
|
261 |
"change the canvas; the container view" |
92cab090c80d
replace obsolete method invocation
Stefan Vogel <sv@exept.de>
parents:
3190
diff
changeset
|
262 |
|
3197 | 263 |
|oldCanvas hadFocus focusView| |
2492 | 264 |
|
265 |
oldCanvas := canvas. |
|
3197 | 266 |
hadFocus := false. |
267 |
||
268 |
(shown and:[newCanvas notNil and:[oldCanvas notNil]]) ifTrue:[ |
|
3269 | 269 |
windowGroup notNil ifTrue:[ |
270 |
focusView := windowGroup focusView. |
|
271 |
]. |
|
3197 | 272 |
(focusView notNil and:[focusView ~~ self]) ifTrue:[ |
273 |
(focusView isComponentOf:oldCanvas) ifTrue:[ |
|
274 |
hadFocus := true. |
|
275 |
]. |
|
276 |
]. |
|
277 |
]. |
|
2492 | 278 |
|
279 |
newCanvas ~~ oldCanvas ifTrue:[ |
|
280 |
oldCanvas notNil ifTrue:[ |
|
281 |
(keepCanvas or:[(oldCanvas objectAttributeAt:#isTabItem) == true]) ifTrue:[ |
|
3197 | 282 |
oldCanvas beInvisible. |
1413 | 283 |
] ifFalse:[ |
2492 | 284 |
oldCanvas destroy. |
1413 | 285 |
]. |
1401 | 286 |
]. |
2492 | 287 |
canvas := newCanvas. |
3197 | 288 |
|
2492 | 289 |
newCanvas notNil ifTrue:[ |
1401 | 290 |
tabModus := false. |
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
291 |
|
1680 | 292 |
self resizeCanvas. |
293 |
||
2492 | 294 |
(subViews size == 0 or:[(subViews includesIdentical:newCanvas) not]) ifTrue:[ |
295 |
self addSubView:newCanvas |
|
1549 | 296 |
]. |
1759 | 297 |
|
3197 | 298 |
shown ifTrue:[ |
299 |
newCanvas beVisible. |
|
2492 | 300 |
newCanvas raise. |
1687 | 301 |
]. |
3197 | 302 |
]. |
303 |
]. |
|
304 |
(shown and:[hadFocus]) ifTrue:[ |
|
305 |
self pushEvent:#updateFocusView |
|
1401 | 306 |
]. |
3269 | 307 |
|
308 |
"Modified: / 05-11-2007 / 14:23:58 / cg" |
|
1401 | 309 |
! |
310 |
||
3336
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
311 |
lastUserSelection |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
312 |
^ lastUserSelection |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
313 |
! |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
314 |
|
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
315 |
lastUserSelection:something |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
316 |
lastUserSelection := something |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
317 |
! |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
318 |
|
1401 | 319 |
list |
320 |
"return the list of Tabs or Labels |
|
321 |
" |
|
322 |
^ list collect:[:aTab| aTab label ] |
|
323 |
||
324 |
! |
|
375 | 325 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
326 |
list:newTabItemListOrNil |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
327 |
"set the tab-list" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
328 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
329 |
|selectionName newList newTabItemList| |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
330 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
331 |
newTabItemList := newTabItemListOrNil ? #(). |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
332 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
333 |
useIndex ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
334 |
selectionName := self selection. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
335 |
]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
336 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
337 |
list do:[:eachTab| |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
338 |
|tabItem| |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
339 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
340 |
((tabItem := eachTab tabItem) notNil and:[(newTabItemList includesIdentical:tabItem)]) ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
341 |
tabItem notNil ifTrue:[tabItem view:nil]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
342 |
eachTab removeDependent:self |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
343 |
] |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
344 |
]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
345 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
346 |
newList := newTabItemList collect: |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
347 |
[:eachNewItem| |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
348 |
|tab| |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
349 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
350 |
(eachNewItem isNil or:[(tab := list detect:[:eachTab| eachTab tabItem == eachNewItem] ifNone:nil) isNil]) ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
351 |
tab := Tab labelOrTabItem:eachNewItem on:self. |
1771 | 352 |
tab addDependent:self. |
353 |
]. |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
354 |
tab |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
355 |
]. |
1771 | 356 |
|
357 |
list := newList. |
|
1401 | 358 |
preferredExtent := nil. |
359 |
numberOfLines := nil. |
|
360 |
||
361 |
selection notNil ifTrue:[ |
|
1433 | 362 |
useIndex ifTrue:[ |
363 |
selection > list size ifTrue:[ |
|
364 |
selection := nil. |
|
365 |
self selectionChanged. |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
366 |
] ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
367 |
model notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
368 |
"/ force a simulated selection change (so that the canvas gets updated) |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
369 |
model changed. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
370 |
] |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
371 |
]. |
1433 | 372 |
] ifFalse:[ |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
373 |
selection := list findFirst:[:el| el label = selectionName ]. |
1433 | 374 |
selection == 0 ifTrue:[ |
375 |
selection := nil. |
|
376 |
self selectionChanged. |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
377 |
] ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
378 |
model notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
379 |
"/ force a simulated selection change (so that the canvas gets updated) |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
380 |
model changed. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
381 |
] |
1433 | 382 |
] |
1401 | 383 |
] |
384 |
]. |
|
1680 | 385 |
self recomputeList. |
386 |
self invalidate. |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
387 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
388 |
"Modified: / 06-09-2006 / 17:10:24 / cg" |
1401 | 389 |
! |
375 | 390 |
|
1401 | 391 |
listIndexOf:something |
2691 | 392 |
"convert something to an index into the list; |
393 |
returns the index or nil if not found |
|
1401 | 394 |
" |
395 |
|index| |
|
396 |
||
397 |
something isNil ifTrue:[^ nil ]. |
|
398 |
||
399 |
something isNumber ifTrue:[ |
|
400 |
index := something |
|
401 |
] ifFalse:[ |
|
402 |
index := list findFirst:[:aTab|aTab label = something]. |
|
403 |
index == 0 ifTrue:[ |
|
404 |
index := list findFirst:[:aTab|aTab printableLabel = something] |
|
405 |
] |
|
406 |
]. |
|
407 |
^ (index between:1 and:list size) ifTrue:[index] ifFalse:[nil] |
|
408 |
! |
|
409 |
||
410 |
useIndex |
|
2691 | 411 |
"use index instead of tab name |
1401 | 412 |
" |
413 |
^ useIndex |
|
414 |
! |
|
415 |
||
416 |
useIndex:aBoolean |
|
417 |
"set/clear the useIndex flag. If set, both actionBlock and change-messages |
|
418 |
are passed the index(indices) of the selection as argument. |
|
419 |
If clear, the value(s) (i.e. the selected string) is passed. |
|
420 |
Default is false." |
|
421 |
||
422 |
useIndex := aBoolean |
|
423 |
||
424 |
||
425 |
! ! |
|
426 |
||
1818 | 427 |
!NoteBookView methodsFor:'accessing-actions'! |
1802 | 428 |
|
429 |
accessTabMenuAction |
|
430 |
"callback to retrieve the menu for a specific tab. |
|
431 |
the argument to the block is the index of the tab |
|
432 |
" |
|
433 |
^ accessTabMenuAction |
|
434 |
! |
|
435 |
||
436 |
accessTabMenuAction:aOneArgAction |
|
437 |
"callback to retrieve the menu for a specific tab. |
|
438 |
the argument to the block is the index of the tab |
|
439 |
" |
|
440 |
accessTabMenuAction := aOneArgAction. |
|
441 |
! |
|
442 |
||
443 |
action |
|
444 |
"get the action block to be performed on select; the argument to |
|
445 |
the block is the selected index or nil in case of no selection. |
|
446 |
" |
|
447 |
^ action |
|
448 |
! |
|
449 |
||
450 |
action:oneArgBlock |
|
451 |
"set the action block to be performed on select; the argument to |
|
452 |
the block is the selected index or nil in case of no selection. |
|
453 |
" |
|
454 |
action := oneArgBlock. |
|
455 |
||
456 |
! ! |
|
457 |
||
1818 | 458 |
!NoteBookView methodsFor:'accessing-behavior'! |
1401 | 459 |
|
2875 | 460 |
destroyTabAction |
461 |
^ destroyTabAction |
|
462 |
! |
|
463 |
||
464 |
destroyTabAction:aOneArgBlock |
|
465 |
destroyTabAction := aOneArgBlock |
|
466 |
! |
|
467 |
||
3179 | 468 |
disableDestroyButtonOfInactiveTabs |
469 |
^ true |
|
470 |
! |
|
471 |
||
1401 | 472 |
enabled |
2875 | 473 |
"returns true if tabs are enabled" |
474 |
||
1401 | 475 |
^ enabled |
476 |
! |
|
477 |
||
478 |
enabled:aState |
|
2875 | 479 |
"set the enabled state of tabs" |
480 |
||
1401 | 481 |
|state| |
482 |
||
483 |
state := aState ? true. |
|
484 |
||
485 |
enabled ~~ state ifTrue:[ |
|
486 |
enabled := state. |
|
487 |
self invalidate. |
|
375 | 488 |
] |
489 |
! |
|
490 |
||
2698 | 491 |
isEnabled |
2875 | 492 |
"returns the enabled state" |
493 |
||
2698 | 494 |
^ enabled |
495 |
! |
|
496 |
||
1413 | 497 |
keepCanvas:aBoolean |
498 |
"if false (the default), the previous canvas is destroyed, whenever |
|
499 |
a new canvas is set. |
|
500 |
if true, it is unmapped and kept. |
|
501 |
Set this flag, if the application changes the canvas but wants |
|
502 |
them to be kept for fast switching." |
|
503 |
||
504 |
keepCanvas := aBoolean. |
|
505 |
! |
|
506 |
||
1401 | 507 |
selectConditionBlock |
508 |
"get the conditionBlock; this block is evaluated before a selection |
|
509 |
change is performed; the change will not be done, if the evaluation |
|
2875 | 510 |
returns false. The argument to the block is the selection index." |
511 |
||
1401 | 512 |
^ selectConditionBlock |
432 | 513 |
! |
514 |
||
1401 | 515 |
selectConditionBlock:aOneArgBlock |
516 |
"get the conditionBlock; this block is evaluated before a selection |
|
517 |
change is performed; the change will not be done, if the evaluation |
|
2875 | 518 |
returns false. The argument to the block is the selection index." |
519 |
||
1401 | 520 |
selectConditionBlock := aOneArgBlock |
2629 | 521 |
! |
522 |
||
3184 | 523 |
showDestroyButtonOfInactiveTabs |
524 |
^ false |
|
525 |
||
526 |
"Created: / 01-03-2007 / 16:41:56 / cg" |
|
527 |
! |
|
528 |
||
2629 | 529 |
translateLabel |
2875 | 530 |
"true if labels are translated" |
531 |
||
2629 | 532 |
^ translateLabel |
533 |
! |
|
534 |
||
535 |
translateLabel:aBoolean |
|
2875 | 536 |
"set to true if labels should be translated" |
537 |
||
2629 | 538 |
translateLabel := aBoolean. |
539 |
! |
|
540 |
||
541 |
translateToDisplayLabel:aString |
|
2875 | 542 |
"translate the label" |
543 |
||
2629 | 544 |
|application builder string| |
545 |
||
546 |
translateLabel ifFalse:[ ^ aString ]. |
|
547 |
||
548 |
aString isEmptyOrNil ifTrue:[ ^ aString ]. |
|
549 |
||
550 |
application := self application. |
|
551 |
application isNil ifTrue:[^ aString ]. |
|
552 |
||
553 |
builder := application builder. |
|
554 |
||
555 |
builder isNil ifTrue:[ |
|
556 |
string := application resources string:aString. |
|
557 |
] ifFalse:[ |
|
558 |
||
559 |
string := builder aspectAt:(aString asSymbol). |
|
560 |
string notNil ifTrue:[^ string ]. |
|
561 |
string := builder resources string:aString. |
|
562 |
]. |
|
563 |
^ string ? aString |
|
432 | 564 |
! ! |
565 |
||
2279 | 566 |
!NoteBookView methodsFor:'accessing-colors'! |
419 | 567 |
|
2760 | 568 |
activeBackgroundColor |
569 |
"returns the bg color used when drawing the active tabs label" |
|
570 |
||
571 |
^ activeBackgroundColor |
|
572 |
! |
|
573 |
||
1442 | 574 |
activeForegroundColor |
2760 | 575 |
"returns the color used when drawing the active tabs label" |
576 |
||
1442 | 577 |
^ activeForegroundColor |
578 |
! |
|
579 |
||
2758 | 580 |
activeTabMarkerColor |
581 |
"win-XP style marker" |
|
582 |
||
2882 | 583 |
^ activeTabMarkerColor |
2758 | 584 |
! |
585 |
||
2763 | 586 |
activeTabMarkerFgColor |
587 |
"win-XP style marker" |
|
588 |
||
2882 | 589 |
^ activeTabMarkerFGColor |
2763 | 590 |
! |
591 |
||
1401 | 592 |
backgroundColor |
2760 | 593 |
"return the backgroundColor of the notebook view" |
594 |
||
595 |
^ backgroundColor |
|
408 | 596 |
! |
597 |
||
2883 | 598 |
destroyTabForegroundColor |
599 |
"returns the color used to draw the destroy button" |
|
600 |
||
601 |
^ foregroundColor. |
|
602 |
||
603 |
"/ foregroundColor brightness < 0.5 ifTrue:[ |
|
604 |
"/ ^ Color grey:40 |
|
605 |
"/ ] ifFalse:[ |
|
606 |
"/ ^ Color grey:60 |
|
607 |
"/ ]. |
|
608 |
! |
|
609 |
||
3179 | 610 |
disabledDestroyTabForegroundColor |
611 |
"returns the color used to draw a disabled destroy button" |
|
612 |
||
613 |
^ disabledForegroundColor. |
|
614 |
||
615 |
"/ foregroundColor brightness < 0.5 ifTrue:[ |
|
616 |
"/ ^ Color grey:40 |
|
617 |
"/ ] ifFalse:[ |
|
618 |
"/ ^ Color grey:60 |
|
619 |
"/ ]. |
|
620 |
! |
|
621 |
||
1700 | 622 |
disabledForegroundColor |
2760 | 623 |
"returns the color used when drawing disabled tab labels" |
624 |
||
1700 | 625 |
^ disabledForegroundColor |
626 |
! |
|
627 |
||
1682 | 628 |
drawLightColor |
2760 | 629 |
"get the color to be used for lighted edges; bug fix caused by common drawEdge" |
630 |
||
1682 | 631 |
^ drawLightColor |
632 |
! |
|
633 |
||
1401 | 634 |
foregroundColor |
2760 | 635 |
"return the color used for drawing text" |
636 |
||
1401 | 637 |
^ foregroundColor |
638 |
! |
|
639 |
||
640 |
foregroundColor:aColor |
|
2760 | 641 |
"set the color to be used for drawing text" |
642 |
||
1401 | 643 |
aColor ~= foregroundColor ifTrue:[ |
644 |
foregroundColor := aColor. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2629
diff
changeset
|
645 |
self invalidate |
1401 | 646 |
] |
419 | 647 |
! |
648 |
||
1401 | 649 |
halfLightColor |
650 |
^ halfLightColor |
|
651 |
! |
|
652 |
||
653 |
halfShadowColor |
|
654 |
^ halfShadowColor |
|
655 |
! |
|
656 |
||
1684 | 657 |
viewBackground:aColor |
3284 | 658 |
aColor isColor ifFalse:[^ self ]. |
659 |
||
660 |
(aColor isColor and:[viewBackground ~= aColor]) ifTrue:[ |
|
661 |
super viewBackground:aColor. |
|
662 |
backgroundColor := viewBackground. |
|
663 |
activeBackgroundColor := backgroundColor. |
|
664 |
||
665 |
backgroundColor brightness < 0.5 ifTrue:[ |
|
3288 | 666 |
foregroundColor := Color white. |
667 |
disabledForegroundColor := Color veryLightGray. |
|
3284 | 668 |
] ifFalse:[ |
669 |
foregroundColor := Color black. |
|
3288 | 670 |
disabledForegroundColor := backgroundColor darker. |
3284 | 671 |
]. |
672 |
activeForegroundColor := foregroundColor. |
|
673 |
]. |
|
375 | 674 |
! ! |
675 |
||
2279 | 676 |
!NoteBookView methodsFor:'accessing-dimension'! |
677 |
||
2881 | 678 |
activeTabMarkerHeight |
679 |
^ 3 |
|
680 |
! |
|
681 |
||
682 |
destroyButtonFrameForTab:aTab |
|
683 |
|l bW bH dX dY bLeft bTop| |
|
684 |
||
685 |
bW := self destroyButtonWidth. |
|
686 |
bH := self destroyButtonHeight. |
|
687 |
dX := self destroyButtonSepX. |
|
688 |
dY := self destroyButtonSepY. |
|
2882 | 689 |
|
2881 | 690 |
l := aTab layout. |
2882 | 691 |
|
2881 | 692 |
bLeft := l right - bW - dX. |
693 |
bTop := l top + dY. |
|
2882 | 694 |
|
3180 | 695 |
(aTab == self selectedTab) ifTrue:[ |
696 |
bTop := bTop + self activeTabMarkerHeight |
|
697 |
]. |
|
698 |
||
2882 | 699 |
^ (bLeft @ bTop) extent:(bW @ bH ) |
2881 | 700 |
! |
701 |
||
2875 | 702 |
destroyButtonHeight |
3180 | 703 |
RemoveTabIcon notNil ifTrue:[^ RemoveTabIcon height]. |
2875 | 704 |
^ 8 |
705 |
! |
|
706 |
||
707 |
destroyButtonSepX |
|
2881 | 708 |
"separating space between tabs right and the destroyButton" |
709 |
||
2882 | 710 |
^ 4 |
3184 | 711 |
|
712 |
"Modified: / 01-03-2007 / 16:45:40 / cg" |
|
2875 | 713 |
! |
714 |
||
715 |
destroyButtonSepY |
|
2881 | 716 |
"separating space between tabs top and the destroyButton" |
717 |
||
3184 | 718 |
RemoveTabIcon notNil ifTrue:[^ 2]. |
2882 | 719 |
^ 3 |
3184 | 720 |
|
721 |
"Modified: / 01-03-2007 / 16:45:19 / cg" |
|
2875 | 722 |
! |
723 |
||
3208 | 724 |
destroyButtonUsedWidth |
725 |
"returns the additional width used for a destroy button |
|
726 |
" |
|
727 |
^ self destroyButtonSepX + self destroyButtonWidth. |
|
728 |
! |
|
729 |
||
2875 | 730 |
destroyButtonWidth |
3180 | 731 |
RemoveTabIcon notNil ifTrue:[^ RemoveTabIcon width]. |
2875 | 732 |
^ 8 |
733 |
! |
|
734 |
||
2280 | 735 |
preferredExtent |
2875 | 736 |
"compute max extent x/y based on one line" |
737 |
||
738 |
|lvl size x y isHorizontal insetX insetY ext| |
|
2280 | 739 |
|
740 |
preferredExtent notNil ifTrue:[ ^ preferredExtent ]. |
|
741 |
||
742 |
x := y := 0. |
|
2875 | 743 |
lvl := (tabLevel abs) max:1. |
2280 | 744 |
size := list size. |
745 |
||
746 |
size ~~ 0 ifTrue:[ |
|
747 |
list do:[:aTab| |
|
2875 | 748 |
|tabExtent| |
749 |
||
750 |
tabExtent := self preferredExtentForTab:aTab. |
|
751 |
x := tabExtent x + x. |
|
752 |
y := tabExtent y max:y. |
|
2280 | 753 |
]. |
754 |
]. |
|
2875 | 755 |
y := y + selectionInsetY + lvl + tabTopMargin + tabBottomMargin. |
756 |
x := x + selectionInsetX + selectionInsetX + (lvl + lvl * size). |
|
2280 | 757 |
|
2284 | 758 |
isHorizontal := self isHorizontal. |
759 |
||
2691 | 760 |
isHorizontal ifTrue:[ |
761 |
x := x + self tabLeftMargin + self tabRightMargin |
|
762 |
] ifFalse:[ |
|
763 |
y := y + self tabLeftMargin + self tabRightMargin |
|
764 |
]. |
|
765 |
||
2284 | 766 |
tabModus ifFalse:[ |
767 |
canvasInset isPoint ifTrue:[ |
|
768 |
insetX := canvasInset x. |
|
769 |
insetY := canvasInset y. |
|
770 |
] ifFalse:[ |
|
771 |
insetX := insetY := canvasInset. |
|
772 |
]. |
|
2875 | 773 |
canvas notNil ifTrue:[ ext := canvas preferredExtent ] |
774 |
ifFalse:[ ext := 100@100 ]. |
|
775 |
||
776 |
y := y + insetY + insetY + ext y. |
|
777 |
x := x max:ext x. |
|
778 |
x := x + insetX + insetX + lvl + lvl. |
|
2284 | 779 |
]. |
780 |
||
781 |
isHorizontal ifTrue:[ ^ x @ y ]. |
|
2431 | 782 |
^ y @ x |
783 |
! |
|
784 |
||
785 |
preferredExtentForTab:aTab |
|
2875 | 786 |
"returns the preferred extent of a specific tab" |
787 |
||
3208 | 788 |
|e| |
2875 | 789 |
|
790 |
e := aTab extent + tabLabelInset. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
791 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
3208 | 792 |
e := e + ((self destroyButtonUsedWidth) @ 0). |
2875 | 793 |
]. |
794 |
^ e. |
|
2279 | 795 |
! ! |
796 |
||
2532 | 797 |
!NoteBookView methodsFor:'accessing-mvc'! |
798 |
||
2698 | 799 |
canvasHolder |
800 |
"get the model, which keeps the canvas, a kind of SimpleView |
|
801 |
" |
|
802 |
^ canvasHolder |
|
803 |
! |
|
804 |
||
805 |
canvasHolder:aValueHolder |
|
806 |
"set the model, which keeps the canvas, a kind of SimpleView |
|
807 |
" |
|
808 |
canvasHolder removeDependent:self. |
|
809 |
||
810 |
(canvasHolder := aValueHolder) notNil ifTrue:[ |
|
811 |
canvasHolder addDependent:self. |
|
812 |
self canvas:(canvasHolder value) |
|
813 |
] |
|
814 |
||
815 |
||
816 |
! |
|
817 |
||
818 |
listHolder |
|
819 |
"get the model, which keeps the list of Tabs or Labels |
|
820 |
" |
|
821 |
^ listHolder |
|
822 |
! |
|
823 |
||
824 |
listHolder:aValueHolder |
|
825 |
"set the model, which keeps the list of Tabs or Labels |
|
826 |
" |
|
827 |
listHolder removeDependent:self. |
|
828 |
||
829 |
(listHolder := aValueHolder) notNil ifTrue:[ |
|
830 |
listHolder addDependent:self. |
|
831 |
self list:listHolder value. |
|
832 |
]. |
|
833 |
! |
|
834 |
||
2532 | 835 |
model:aValueHolder |
2533 | 836 |
"set the model, which keeps the selection" |
837 |
||
2532 | 838 |
super model:aValueHolder. |
839 |
||
840 |
model notNil ifTrue:[ |
|
841 |
self selection:(model value) |
|
842 |
] |
|
843 |
! ! |
|
844 |
||
1818 | 845 |
!NoteBookView methodsFor:'accessing-style'! |
1401 | 846 |
|
2279 | 847 |
canvasInset |
848 |
"inset of the canvas relative to my frame |
|
849 |
tabLevel + canvasInset == origin of canvas |
|
850 |
" |
|
851 |
^ canvasInset |
|
852 |
! |
|
853 |
||
854 |
canvasInset:anInset |
|
855 |
"inset of the canvas relative to my frame |
|
856 |
tabLevel + canvasInset == origin of canvas |
|
857 |
" |
|
858 |
anInset ~~ canvasInset ifTrue:[ |
|
859 |
canvasInset := anInset. |
|
2282 | 860 |
self styleChanged. |
2279 | 861 |
]. |
862 |
! |
|
863 |
||
1401 | 864 |
direction |
865 |
"returns the direction of tabs as symbol. On default the value is |
|
866 |
set to #top. Valid symbols are: |
|
867 |
#top arrange tabs to be on top of a view |
|
868 |
#bottom arrange tabs to be on bottom of a view |
|
869 |
#left arrange tabs to be on left of a view |
|
870 |
#right arrange tabs to be on right of a view |
|
871 |
" |
|
872 |
^ direction |
|
873 |
||
874 |
! |
|
875 |
||
876 |
direction:aDirection |
|
877 |
"change the direction of tabs. On default the value is set to #top. |
|
878 |
Valid symbols are: |
|
879 |
#top arrange tabs to be on top of a view |
|
880 |
#bottom arrange tabs to be on bottom of a view |
|
881 |
#left arrange tabs to be on left of a view |
|
882 |
#right arrange tabs to be on right of a view |
|
883 |
" |
|
884 |
direction ~~ aDirection ifTrue:[ |
|
2282 | 885 |
direction := aDirection. |
886 |
self styleChanged. |
|
1401 | 887 |
]. |
888 |
! |
|
375 | 889 |
|
1401 | 890 |
fitLastRow |
891 |
"in case of true, the last row is expanded to the view size like all |
|
892 |
other raws. In case of false all the tabs in the last raw keep their |
|
893 |
preferred extent (x or y) dependant on the direction. |
|
894 |
" |
|
895 |
^ fitLastRow |
|
896 |
! |
|
897 |
||
898 |
fitLastRow:aBool |
|
899 |
"in case of true, the last row is expanded to the view size like all |
|
900 |
other raws. In case of false all the tabs in the last raw keep their |
|
901 |
preferred extent (x or y) dependant on the direction. |
|
375 | 902 |
" |
2282 | 903 |
|
904 |
fitLastRow ~~ aBool ifTrue:[ |
|
905 |
fitLastRow := aBool. |
|
906 |
self styleChanged. |
|
907 |
]. |
|
908 |
! |
|
909 |
||
2698 | 910 |
hasScrollButtons |
911 |
^ buttonNext notNil |
|
912 |
! |
|
913 |
||
914 |
hasScrollButtons:aBoolean |
|
915 |
|hasScrollButtons| |
|
916 |
||
917 |
hasScrollButtons := self hasScrollButtons. |
|
918 |
hasScrollButtons == aBoolean ifTrue:[^ self]. |
|
919 |
||
920 |
hasScrollButtons ifTrue:[ |
|
921 |
buttonNext destroy. |
|
922 |
buttonPrev destroy. |
|
923 |
buttonNext := buttonPrev := nil. |
|
924 |
] ifFalse:[ |
|
925 |
buttonNext := ArrowButton in:self. |
|
926 |
buttonPrev := ArrowButton in:self. |
|
927 |
||
928 |
buttonNext beInvisible. |
|
929 |
buttonPrev beInvisible. |
|
930 |
||
931 |
"/ realized ifTrue:[ |
|
932 |
"/ buttonNext create. "/ realize. |
|
933 |
"/ buttonPrev create. "/ realize. |
|
934 |
"/ ]. |
|
935 |
buttonNext action:[ self scrollButtonPressed:#scrollRight ]. |
|
936 |
buttonPrev action:[ self scrollButtonPressed:#scrollLeft ]. |
|
937 |
]. |
|
938 |
self styleChanged. |
|
939 |
! |
|
940 |
||
941 |
isHorizontal |
|
942 |
"returns true in case of direction is #top or #bottom |
|
943 |
" |
|
944 |
^ direction == #top or:[direction == #bottom] |
|
945 |
! |
|
946 |
||
2875 | 947 |
showDestroyTabButton |
948 |
^ showDestroyTabButton |
|
949 |
! |
|
950 |
||
951 |
showDestroyTabButton:aBoolean |
|
952 |
showDestroyTabButton == aBoolean ifTrue:[^ self]. |
|
953 |
showDestroyTabButton := aBoolean. |
|
954 |
||
955 |
self styleChanged. |
|
956 |
! |
|
957 |
||
2282 | 958 |
tabBottomMargin |
959 |
"returns the margin between the tabs and the canvas |
|
960 |
" |
|
961 |
^ tabBottomMargin |
|
962 |
! |
|
963 |
||
964 |
tabBottomMargin:aMargin |
|
965 |
"set the margin between the tabs and the canvas |
|
966 |
" |
|
967 |
|margin| |
|
968 |
||
969 |
margin := aMargin max:0. |
|
970 |
||
971 |
margin ~~ tabBottomMargin ifTrue:[ |
|
972 |
tabBottomMargin := margin. |
|
973 |
self styleChanged. |
|
974 |
]. |
|
1401 | 975 |
! |
976 |
||
2431 | 977 |
tabLabelInset |
978 |
"inset (a point) of the label relative to its frame |
|
979 |
preferredExtent of Tab: label extent + tabLabelInset |
|
980 |
" |
|
981 |
^ tabLabelInset |
|
982 |
! |
|
983 |
||
984 |
tabLabelInset:aPoint |
|
985 |
"inset (a point) of the label relative to its frame |
|
986 |
preferredExtent of Tab: label extent + tabLabelInset |
|
987 |
" |
|
988 |
|p| |
|
989 |
||
990 |
aPoint isNumber ifTrue:[ p := Point x:aPoint y:aPoint ] |
|
991 |
ifFalse:[ p := aPoint ]. |
|
992 |
||
993 |
p ~= tabLabelInset ifTrue:[ |
|
994 |
tabLabelInset := p. |
|
995 |
self styleChanged. |
|
996 |
]. |
|
997 |
! |
|
998 |
||
2691 | 999 |
tabLeftMargin |
1000 |
"margin to the first visible tab or scroller button |
|
1001 |
" |
|
1002 |
^ tabLeftMargin |
|
1003 |
! |
|
1004 |
||
1005 |
tabLeftMargin:aMargin |
|
1006 |
"margin to the first visible tab or scroller button |
|
1007 |
" |
|
1008 |
|margin| |
|
1009 |
||
1010 |
margin := aMargin max:0. |
|
1011 |
||
1012 |
margin ~~ tabLeftMargin ifTrue:[ |
|
1013 |
tabLeftMargin := margin. |
|
1014 |
self styleChanged. |
|
1015 |
]. |
|
1016 |
! |
|
1017 |
||
2279 | 1018 |
tabLevel |
1019 |
"the level of the tabs and noteBook frame |
|
1020 |
" |
|
1021 |
^ tabLevel |
|
1401 | 1022 |
! |
375 | 1023 |
|
2279 | 1024 |
tabLevel:aLevel |
1025 |
"the level of the tabs and noteBook frame |
|
1026 |
" |
|
1027 |
aLevel ~~ tabLevel ifTrue:[ |
|
1028 |
tabLevel := aLevel. |
|
2282 | 1029 |
self styleChanged. |
1030 |
]. |
|
1031 |
! |
|
1032 |
||
2691 | 1033 |
tabRightMargin |
1034 |
"margin from the last visible tab or scroller button to the view |
|
1035 |
" |
|
1036 |
^ tabRightMargin |
|
1037 |
! |
|
1038 |
||
1039 |
tabRightMargin:aMargin |
|
1040 |
"margin from the last visible tab or scroller button to the view |
|
1041 |
" |
|
1042 |
|margin| |
|
1043 |
||
1044 |
margin := aMargin max:0. |
|
1045 |
||
1046 |
margin ~~ tabRightMargin ifTrue:[ |
|
1047 |
tabRightMargin := margin. |
|
1048 |
self styleChanged. |
|
1049 |
]. |
|
1050 |
! |
|
1051 |
||
2282 | 1052 |
tabTopMargin |
2691 | 1053 |
"returns the margin between the tabs and the widget (not canvas) |
2282 | 1054 |
" |
1055 |
^ tabTopMargin |
|
1056 |
! |
|
1057 |
||
1058 |
tabTopMargin:aMargin |
|
2691 | 1059 |
"set the margin between the tabs and the widget (not canvas) |
2282 | 1060 |
" |
1061 |
|margin| |
|
1062 |
||
1063 |
margin := aMargin max:0. |
|
1064 |
||
1065 |
margin ~~ tabTopMargin ifTrue:[ |
|
1066 |
tabTopMargin := margin. |
|
1067 |
self styleChanged. |
|
2279 | 1068 |
]. |
375 | 1069 |
! ! |
1070 |
||
1071 |
!NoteBookView methodsFor:'change & update'! |
|
1072 |
||
2282 | 1073 |
styleChanged |
1074 |
"called if the tab style changed |
|
1075 |
list must be recomputed |
|
1076 |
" |
|
1077 |
preferredExtent := nil. |
|
1078 |
||
1079 |
numberOfLines isNil ifTrue:[ |
|
1080 |
^ self. "/ layout not yet computed |
|
1081 |
]. |
|
1082 |
self recomputeList. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2629
diff
changeset
|
1083 |
self invalidate |
2282 | 1084 |
! |
1085 |
||
1401 | 1086 |
update:something with:aParameter from:changedObject |
1087 |
"one of my models changed its value |
|
1088 |
" |
|
1089 |
|idx tab| |
|
1090 |
||
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
1091 |
changedObject == model ifTrue:[ self selection:model value. ^ self]. |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1092 |
changedObject == listHolder ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1093 |
something == #at: ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1094 |
"/ a single items label has changed |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1095 |
self tabAtIndex:aParameter put:(listHolder value at:aParameter). |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1096 |
^ self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1097 |
]. |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
1098 |
self list:(listHolder value). |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
1099 |
^ self |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1100 |
]. |
1401 | 1101 |
changedObject == enableChannel ifTrue:[^ self enabled:enableChannel value]. |
1413 | 1102 |
changedObject == canvasHolder ifTrue:[^ self canvas:canvasHolder value]. |
1401 | 1103 |
|
1104 |
(idx := list findFirst:[:aTab| aTab label == changedObject]) ~~ 0 ifTrue:[ |
|
1105 |
tab := list at:idx. |
|
1106 |
||
1107 |
idx == selection ifTrue:[ |
|
1108 |
tab isEnabled ifFalse:[ |
|
1109 |
^ self selection:nil |
|
1110 |
] |
|
1111 |
]. |
|
1112 |
tab label:(tab label) on:self. |
|
2529 | 1113 |
self invalidateTab:tab. |
1114 |
^ self. |
|
1115 |
]. |
|
1116 |
||
1117 |
^ super update:something with:aParameter from:changedObject |
|
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1118 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
1119 |
"Modified: / 06-09-2006 / 11:38:23 / cg" |
1401 | 1120 |
! ! |
1121 |
||
1122 |
!NoteBookView methodsFor:'drawing'! |
|
1123 |
||
2691 | 1124 |
computeDrawingClipX:x y:y width:w height:h |
1125 |
|trans xOrY wOrHInset| |
|
1126 |
||
1127 |
self hasScrollButtons ifFalse:[^ nil]. |
|
1128 |
||
1129 |
trans := self transformation. |
|
1130 |
xOrY := self tabLeftMargin. |
|
1131 |
wOrHInset := self tabRightMargin + xOrY. |
|
1132 |
||
1133 |
self isHorizontal ifTrue:[ |
|
1134 |
trans notNil ifTrue:[ |
|
1135 |
xOrY := trans applyInverseToX:xOrY. |
|
1136 |
]. |
|
1137 |
^ Rectangle left:xOrY top:y width:(self width - wOrHInset) height:h. |
|
1138 |
]. |
|
1139 |
trans notNil ifTrue:[ |
|
1140 |
xOrY := trans applyInverseToY:xOrY. |
|
1141 |
]. |
|
1142 |
^ Rectangle left:x top:xOrY width:w height:(self height - wOrHInset) |
|
1143 |
! |
|
1144 |
||
2763 | 1145 |
drawActiveTabMarker:aTab |
1146 |
"draw a tabs focus-rectangle" |
|
1147 |
||
1148 |
|layout w h yRct yPnt xRct xPnt incY incX markerHeight fgColor bgColor| |
|
1149 |
||
1150 |
layout := aTab layout. |
|
2881 | 1151 |
markerHeight := self activeTabMarkerHeight. |
2763 | 1152 |
|
1153 |
bgColor := self activeTabMarkerColor. |
|
1154 |
fgColor := self activeTabMarkerFgColor. |
|
1155 |
||
1156 |
self isHorizontal ifTrue:[ |
|
1157 |
xPnt := layout left + 1. |
|
1158 |
w := layout width - 2. |
|
1159 |
h := markerHeight. |
|
1160 |
||
1161 |
direction == #top ifTrue:[ |
|
1162 |
yPnt := yRct := layout top. |
|
1163 |
incY := 1. |
|
1164 |
] ifFalse:[ |
|
1165 |
incY := -1. |
|
1166 |
yRct := layout bottom - h. |
|
1167 |
yPnt := layout bottom - 1. |
|
1168 |
]. |
|
1169 |
bgColor notNil ifTrue:[ |
|
1170 |
self paint:bgColor. |
|
1171 |
self fillRectangleX:xPnt y:yRct width:w height:h. |
|
1172 |
]. |
|
1173 |
fgColor notNil ifTrue:[ |
|
1174 |
self paint:fgColor. |
|
1175 |
self displayLineFromX:xPnt y:yPnt toX:(xPnt + w - 1) y:yPnt. |
|
1176 |
||
1177 |
(markerHeight - 1) timesRepeat:[ |
|
1178 |
yPnt := yPnt + incY. |
|
1179 |
self displayPointX:(xPnt - 1) y:yPnt. |
|
1180 |
self displayPointX:(xPnt + w) y:yPnt. |
|
1181 |
]. |
|
1182 |
]. |
|
1183 |
] ifFalse:[ |
|
1184 |
w := markerHeight. |
|
1185 |
h := layout height - 2. |
|
1186 |
yRct := layout top + 1. |
|
1187 |
||
1188 |
direction == #left ifTrue:[ |
|
1189 |
incX := 1. |
|
1190 |
xRct := xPnt := layout left. |
|
1191 |
] ifFalse:[ |
|
1192 |
incX := -1. |
|
1193 |
xRct := layout right - w. |
|
1194 |
xPnt := layout right - 1. |
|
1195 |
]. |
|
1196 |
||
1197 |
bgColor notNil ifTrue:[ |
|
1198 |
self paint:bgColor. |
|
1199 |
self fillRectangleX:xRct y:yRct width:w height:h. |
|
1200 |
]. |
|
1201 |
||
1202 |
fgColor notNil ifTrue:[ |
|
1203 |
self paint:fgColor. |
|
1204 |
self displayLineFromX:xPnt y:yRct toX:xPnt y:yRct + h - 1. |
|
1205 |
||
1206 |
(markerHeight - 1) timesRepeat:[ |
|
1207 |
xPnt := xPnt + incX. |
|
1208 |
self displayPointX:xPnt y:(yRct - 1). |
|
1209 |
self displayPointX:xPnt y:(yRct + h). |
|
1210 |
]. |
|
1211 |
]. |
|
1212 |
]. |
|
1213 |
! |
|
1214 |
||
2283 | 1215 |
drawBorderEdges |
2686 | 1216 |
|layout x0 x1 y0 y1 trans| |
2283 | 1217 |
|
1218 |
"/ test whether TabView and not NoteBookView |
|
1219 |
tabModus ifTrue:[^ self]. |
|
1220 |
||
1221 |
layout := self computeBorderLayout. |
|
1222 |
||
1223 |
tabLevel ~~ 0 ifTrue:[ |
|
1224 |
self drawEdgesForX:(layout left) |
|
1225 |
y:(layout top) |
|
1226 |
width:(layout width) |
|
1227 |
height:(layout height) |
|
1228 |
level:tabLevel. |
|
1229 |
^ self |
|
1230 |
]. |
|
1231 |
list size > 1 ifFalse:[^ self]. |
|
1232 |
||
1233 |
self paint:lightColor ? lightColor. |
|
2686 | 1234 |
trans := self transformation. |
2283 | 1235 |
|
1236 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
1237 |
direction == #top ifTrue:[ y0 := layout top - 1 ] |
|
2284 | 1238 |
ifFalse:[ y0 := layout bottom ]. |
2283 | 1239 |
y1 := y0. |
1240 |
x0 := 0. |
|
2686 | 1241 |
trans notNil ifTrue:[ |
1242 |
x0 := trans applyInverseToX:x0. |
|
1243 |
]. |
|
2691 | 1244 |
x1 := x0 + self width. |
2283 | 1245 |
] ifFalse:[ |
1246 |
direction == #left ifTrue:[ x0 := layout left - 1 ] |
|
1247 |
ifFalse:[ x0 := layout right ]. |
|
2686 | 1248 |
x1 := x0. |
2283 | 1249 |
y0 := 0. |
2686 | 1250 |
trans notNil ifTrue:[ |
1251 |
y0 := trans applyInverseToY:y0. |
|
1252 |
]. |
|
2691 | 1253 |
y1 := y0 + self height. |
2283 | 1254 |
]. |
1255 |
self displayLineFromX:x0 y:y0 toX:x1 y:y1. |
|
1256 |
! |
|
1257 |
||
2875 | 1258 |
drawDestroyButtonForTab:aTab |
1259 |
"redraw a tabs destroy button" |
|
1260 |
||
3208 | 1261 |
|bFrame showEnabled icon| |
2875 | 1262 |
|
1263 |
bFrame := self destroyButtonFrameForTab:aTab. |
|
3180 | 1264 |
showEnabled := (self disableDestroyButtonOfInactiveTabs not |
1265 |
or:[ aTab == self selectedTab ]). |
|
1266 |
||
1267 |
RemoveTabIcon notNil ifTrue:[ |
|
1268 |
removeTabIcon isNil ifTrue:[ |
|
1269 |
removeTabIcon := RemoveTabIcon onDevice:(self device). |
|
1270 |
removeTabEnteredIcon := RemoveTabEnteredIcon onDevice:(self device). |
|
1271 |
removeTabDisabledIcon := (removeTabIcon asGrayImageDepth:4) lightened lightened. |
|
1272 |
removeTabDisabledIcon mask:(removeTabIcon mask copy). |
|
1273 |
removeTabDisabledIcon := removeTabDisabledIcon onDevice:(self device). |
|
1274 |
]. |
|
3208 | 1275 |
showEnabled ifTrue:[ |
1276 |
showingEnteredRemoveTabButton ifTrue:[icon := removeTabEnteredIcon] |
|
1277 |
ifFalse:[icon := removeTabIcon]. |
|
1278 |
] ifFalse:[ |
|
1279 |
icon := removeTabDisabledIcon. |
|
1280 |
]. |
|
1281 |
icon displayOn:self at:bFrame origin. |
|
3179 | 1282 |
] ifFalse:[ |
3180 | 1283 |
self paint:(showEnabled |
1284 |
ifTrue:[self destroyTabForegroundColor] |
|
1285 |
ifFalse:[self disabledDestroyTabForegroundColor]). |
|
1286 |
||
1287 |
self displayRectangle:bFrame. |
|
1288 |
self displayLineFrom:bFrame topLeft to:bFrame bottomRight-(1@1). |
|
1289 |
self displayLineFrom:bFrame topRight - (1@0) to:bFrame bottomLeft-(0@1). |
|
1290 |
] |
|
2875 | 1291 |
! |
1292 |
||
2278 | 1293 |
drawTabEdgesFor:aTab |
2763 | 1294 |
|layout count leftFg leftHalfFg rightFg x0 x1 y0 y1 isSelected |
2278 | 1295 |
yT "{ Class:SmallInteger }" |
1296 |
xL "{ Class:SmallInteger }" |
|
1297 |
xR "{ Class:SmallInteger }" |
|
1298 |
yB "{ Class:SmallInteger }" |
|
1299 |
| |
|
2758 | 1300 |
|
2280 | 1301 |
count := tabLevel. |
1302 |
isSelected := (self selectedTab == aTab). |
|
2278 | 1303 |
|
2283 | 1304 |
count <= 0 ifTrue:[ |
2280 | 1305 |
isSelected ifFalse:[ ^ self ]. |
1306 |
||
2283 | 1307 |
count == 0 ifTrue:[ |
1308 |
list size > 1 ifFalse:[^ self]. |
|
1309 |
count := 1 |
|
1310 |
] ifFalse:[ |
|
1311 |
count := count negated |
|
1312 |
]. |
|
1313 |
||
2278 | 1314 |
rightFg := lightColor. |
1315 |
leftFg := shadowColor. |
|
1316 |
leftHalfFg := halfShadowColor. |
|
1317 |
] ifFalse:[ |
|
1318 |
((edgeStyle == #soft) and:[tabLevel > 1]) ifTrue:[ rightFg := halfShadowColor ] |
|
2280 | 1319 |
ifFalse:[ rightFg := shadowColor ]. |
2278 | 1320 |
leftFg := lightColor. |
1321 |
leftHalfFg := halfLightColor. |
|
1322 |
]. |
|
1323 |
||
1324 |
(leftHalfFg notNil and:[edgeStyle == #soft and:[tabLevel > 0]]) ifTrue:[ |
|
1325 |
leftFg := leftHalfFg |
|
1326 |
]. |
|
1327 |
||
1328 |
layout := aTab layout. |
|
1329 |
xL := layout left. |
|
1330 |
yT := layout top. |
|
1331 |
xR := layout right - 1. |
|
1332 |
yB := layout bottom - 1. |
|
1333 |
||
1334 |
x0 := xL + count. |
|
1335 |
x1 := xR - count. |
|
1336 |
y0 := yT + count. |
|
1337 |
y1 := yB - count. |
|
1338 |
||
1339 |
direction == #top ifTrue:[ |
|
1340 |
self paint:rightFg. |
|
1341 |
||
1342 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
1343 |
self displayLineFromX:xR - i y:yB toX:xR - i y:y0 - i. |
|
1344 |
]. |
|
1345 |
||
1346 |
self paint:leftFg. |
|
1347 |
||
1348 |
0 to:count - 1 do:[:i| "/ horizontal: left |
|
1349 |
self displayLineFromX:xL + i y:y0 - i toX:xL + i y:yB. |
|
1350 |
]. |
|
1351 |
||
1352 |
0 to:count - 1 do:[:i| "/ horizontal: top |
|
1353 |
self displayLineFromX:x0 - i y:yT + i toX:x1 y:yT + i. |
|
1354 |
]. |
|
2280 | 1355 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
1356 |
(self isLastTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 1357 |
|
1358 |
y0 := yB + 1. |
|
1359 |
x1 := x1 + 1. |
|
1360 |
||
1361 |
1 to:count - 1 do:[:i| "/ horizontal line |
|
1362 |
self displayLineFromX:x1 + i y:y0 - i toX:xR y:y0 - i. |
|
1363 |
]. |
|
2758 | 1364 |
|
2278 | 1365 |
^ self |
1366 |
]. |
|
1367 |
||
1368 |
direction == #bottom ifTrue:[ |
|
1369 |
self paint:leftFg. |
|
1370 |
||
1371 |
0 to:count - 1 do:[:i| "/ vertical : left |
|
1372 |
self displayLineFromX:xL + i y:yT toX:xL + i y:y1+i. |
|
1373 |
]. |
|
1374 |
||
1375 |
self paint:rightFg. |
|
1376 |
||
1377 |
0 to:count - 1 do:[:i| "/ horizontal: bottom |
|
1378 |
self displayLineFromX:x0 y:yB-i toX:x1 + i y:yB-i. |
|
1379 |
]. |
|
1380 |
||
1381 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
1382 |
self displayLineFromX:xR-i y:yT toX:xR-i y:y1+i. |
|
1383 |
]. |
|
1384 |
||
2280 | 1385 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
1386 |
(self isFirstTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 1387 |
|
1388 |
x0 := x0 - 1. |
|
1389 |
y0 := yT - 1. |
|
1390 |
||
1391 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
1392 |
self displayLineFromX:xL y:y0 + i toX:x0-i y:y0 + i. |
|
1393 |
]. |
|
1394 |
^ self |
|
1395 |
]. |
|
1396 |
||
1397 |
direction == #right ifTrue:[ |
|
1398 |
self paint:leftFg. |
|
1399 |
||
1400 |
0 to:count - 1 do:[:i| "/ horizontal: top |
|
1401 |
self displayLineFromX:xL y:yT + i toX:x1+i y:yT + i. |
|
1402 |
]. |
|
1403 |
||
1404 |
self paint:rightFg. |
|
1405 |
||
1406 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
1407 |
self displayLineFromX:xR-i y:y0 toX:xR-i y:y1. |
|
1408 |
]. |
|
1409 |
||
1410 |
1 to:count do:[:i| "/ horizontal: bottom |
|
1411 |
self displayLineFromX:xL y:y1+i toX:xR-i y:y1+i. |
|
1412 |
]. |
|
1413 |
||
2280 | 1414 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
2278 | 1415 |
(self isFirstTabInLine:aTab) ifTrue:[^ self]. |
1416 |
||
1417 |
x0 := x0 - 1. |
|
1418 |
y0 := yT - 1. |
|
1419 |
||
1420 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
1421 |
self displayLineFromX:xL y:y0 + i toX:x0-i y:y0 + i. |
|
1422 |
]. |
|
1423 |
^ self |
|
1424 |
]. |
|
1425 |
||
1426 |
"/ direction == #left |
|
1427 |
self paint:rightFg. |
|
1428 |
||
1429 |
x0 := xL + count. |
|
1430 |
x1 := xR - count. |
|
1431 |
y0 := yT + count. |
|
1432 |
y1 := yB - count. |
|
1433 |
||
1434 |
0 to:count - 1 do:[:i| "/ horizontal: bottom |
|
1435 |
self displayLineFromX:x0 - i y:yB - i toX:xR y:yB - i. |
|
1436 |
]. |
|
1437 |
||
1438 |
self paint:leftFg. |
|
1439 |
||
1440 |
0 to:count - 1 do:[:i| "/ vertical: left |
|
1441 |
self displayLineFromX:xL + i y:y0 toX:xL + i y:y1. |
|
1442 |
]. |
|
1443 |
||
1444 |
1 to:count do:[:i| "/ horizontal: top |
|
1445 |
self displayLineFromX:xL + i y:y0 - i toX:xR y:y0 - i. |
|
1446 |
]. |
|
1447 |
||
2280 | 1448 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
1449 |
(self isLastTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 1450 |
|
1451 |
x1 := x1 + 1. |
|
1452 |
y0 := yB + 1. |
|
1453 |
||
1454 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
1455 |
self displayLineFromX:x1+i y:yB + 1 - i toX:xR y:yB + 1 - i. |
|
1456 |
]. |
|
1457 |
! |
|
1458 |
||
2762 | 1459 |
drawTabFocus:aTab |
1460 |
"draw a tabs focus-rectangle" |
|
1461 |
||
3208 | 1462 |
|tabLyt extent top lft x y w h bW| |
2762 | 1463 |
|
3177 | 1464 |
self supportsFocusOnTab ifFalse:[ ^ self ]. |
3186 | 1465 |
|
1466 |
tabLyt := aTab layout. |
|
2762 | 1467 |
extent := aTab extent. |
3208 | 1468 |
top := tabLyt top. |
1469 |
lft := tabLyt left. |
|
1470 |
||
1471 |
(self isDestroyTabButtonShownFor:aTab) ifTrue:[ |
|
1472 |
bW := self destroyButtonUsedWidth. |
|
2762 | 1473 |
] ifFalse:[ |
3208 | 1474 |
bW := 0. |
2762 | 1475 |
]. |
3208 | 1476 |
self isHorizontal ifTrue:[ |
1477 |
w := extent x + 4. |
|
1478 |
h := extent y + 2. |
|
1479 |
x := lft + ((tabLyt width - w - bW) // 2). |
|
1480 |
y := top + ((tabLyt height - h) // 2). |
|
1481 |
||
1482 |
direction == #top ifTrue:[ |
|
1483 |
y := y + 1. |
|
1484 |
]. |
|
1485 |
] ifFalse:[ |
|
1486 |
w := extent y + 2. |
|
1487 |
h := extent x + 4. |
|
1488 |
y := top + ((tabLyt height - h - bW) // 2). |
|
1489 |
x := lft + ((tabLyt width - w) // 2). |
|
1490 |
||
1491 |
direction == #left ifTrue:[ |
|
1492 |
x := x + 1. |
|
1493 |
]. |
|
1494 |
]. |
|
2762 | 1495 |
self paint:(Color black). |
1496 |
||
3208 | 1497 |
self displayDottedRectangleX:(x max:lft) |
1498 |
y:(y max:top) |
|
1499 |
width:w height:h. |
|
2762 | 1500 |
! |
1501 |
||
1502 |
invalidateSelectedTab |
|
1503 |
|selectedTab| |
|
1504 |
||
1505 |
selectedTab := self selectedTab. |
|
1506 |
selectedTab notNil ifTrue:[ |
|
1507 |
self invalidateTab:selectedTab |
|
1508 |
]. |
|
1509 |
! |
|
1510 |
||
1401 | 1511 |
invalidateTab:aTab |
2762 | 1512 |
"invalidate a tab (i.e. force it to be redrawn)" |
1513 |
||
1401 | 1514 |
shown ifTrue:[ |
2896 | 1515 |
self invalidate:(self computeLayoutForTab:aTab). |
1401 | 1516 |
] |
1517 |
! |
|
1518 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1519 |
redrawTab:aTab |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1520 |
"redraw a tab" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1521 |
|
3208 | 1522 |
|isSelected fgColor buttonInset| |
2288 | 1523 |
|
3179 | 1524 |
isSelected := (self selectedTab == aTab). |
2288 | 1525 |
|
2906 | 1526 |
aTab layout isNil ifTrue:[^ self ]. |
1527 |
||
2875 | 1528 |
self paint:(isSelected ifTrue:[self activeBackgroundColor] ifFalse:[self backgroundColor]). |
1529 |
self fillRectangle:(aTab layout). |
|
2288 | 1530 |
|
1531 |
(enabled and:[aTab isEnabled]) ifFalse:[ |
|
1532 |
fgColor := disabledForegroundColor. |
|
1533 |
] ifTrue:[ |
|
1534 |
fgColor := aTab foregroundColor. |
|
1535 |
fgColor isNil ifTrue:[ |
|
2875 | 1536 |
fgColor := isSelected ifTrue:[activeForegroundColor] ifFalse:[foregroundColor]. |
2288 | 1537 |
] |
1538 |
]. |
|
3208 | 1539 |
(self isDestroyTabButtonShownFor:aTab) ifTrue:[ |
1540 |
buttonInset := self destroyButtonUsedWidth. |
|
1541 |
] ifFalse:[ |
|
1542 |
buttonInset := 0. |
|
1543 |
]. |
|
1544 |
||
2288 | 1545 |
self paint:fgColor. |
3208 | 1546 |
aTab displayOn:self inset:(tabLevel abs) direction:direction textRightInset:buttonInset. |
1547 |
||
1548 |
buttonInset > 0 ifTrue:[ |
|
2875 | 1549 |
self drawDestroyButtonForTab:aTab. |
1550 |
]. |
|
2288 | 1551 |
self drawTabEdgesFor:aTab. |
1552 |
||
2763 | 1553 |
isSelected ifTrue:[ |
3186 | 1554 |
self activeTabMarkerColor notNil ifTrue:[ |
1555 |
self drawActiveTabMarker:aTab. |
|
1556 |
]. |
|
1557 |
self hasFocus ifTrue:[ |
|
1558 |
self drawTabFocus:aTab |
|
1559 |
]. |
|
2288 | 1560 |
]. |
1561 |
! |
|
1562 |
||
1401 | 1563 |
redrawX:x y:y width:w height:h |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1564 |
"a region must be redrawn" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1565 |
|
3291 | 1566 |
|selectedTab line damage tabLayout clip myRectangle borderLayout| |
1401 | 1567 |
|
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1568 |
shown ifFalse:[ ^ self ]. |
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1569 |
|
2283 | 1570 |
numberOfLines isNil ifTrue:[ |
1401 | 1571 |
self recomputeList. |
2215 | 1572 |
|
2283 | 1573 |
numberOfLines notNil ifTrue:[ |
2215 | 1574 |
self invalidate |
1575 |
]. |
|
1576 |
^ self |
|
1401 | 1577 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1578 |
|
2213 | 1579 |
selectedTab := self selectedTab. |
2283 | 1580 |
selectedTab notNil ifTrue:[ |
2288 | 1581 |
(line := selectedTab lineNr) ~~ 1 ifTrue:[ |
1582 |
self makeToBaseLine:line. |
|
2760 | 1583 |
^ self |
2283 | 1584 |
] |
1401 | 1585 |
]. |
3291 | 1586 |
damage := Rectangle left:x top:y width:w height:h. |
1587 |
||
1588 |
"/ draw the damage intersects the tabs with my superViews background |
|
1589 |
borderLayout := self computeBorderLayout. |
|
1590 |
||
1591 |
(borderLayout intersects:damage) ifTrue:[ |
|
1592 |
self clearRectangle:borderLayout. |
|
1593 |
]. |
|
1594 |
myRectangle := Rectangle origin:0@0 extent:self extent. |
|
1595 |
||
1596 |
(myRectangle areasOutside:borderLayout) do:[:r| |
|
1597 |
(r intersects:damage) ifTrue:[ |
|
1598 |
self paint:(superView viewBackground). |
|
1599 |
self fillRectangle:r. |
|
1600 |
]. |
|
1601 |
]. |
|
2283 | 1602 |
list size == 0 ifTrue:[ ^ self ]. |
1603 |
||
2691 | 1604 |
self drawBorderEdges. |
1605 |
||
2896 | 1606 |
clip := self computeDrawingClipX:x y:y width:w height:h. |
2278 | 1607 |
|
1608 |
numberOfLines to:1 by:-1 do:[:aLnNr| |
|
1609 |
list reverseDo:[:aTab| |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1610 |
(aTab lineNr == aLnNr |
2278 | 1611 |
and:[aTab ~~ selectedTab |
1612 |
and:[aTab intersects:damage]] |
|
1613 |
) ifTrue:[ |
|
2691 | 1614 |
clip notNil ifTrue:[ |
1615 |
self clippingRectangle:clip. |
|
1616 |
clip := nil. |
|
1617 |
]. |
|
2288 | 1618 |
self redrawTab:aTab. |
1401 | 1619 |
] |
1620 |
] |
|
1621 |
]. |
|
2691 | 1622 |
selectedTab isNil ifTrue:[ |
1623 |
^ self |
|
1624 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1625 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1626 |
tabLayout := self computeLayoutForTab:selectedTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1627 |
(tabLayout intersects:damage) ifTrue:[ |
2691 | 1628 |
clip notNil ifTrue:[ |
1629 |
self clippingRectangle:clip. |
|
1630 |
clip := nil. |
|
1631 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1632 |
"/ selectedLayout := selectedTab layout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1633 |
"/ selectedTab layout:layout. |
2288 | 1634 |
self redrawTab:selectedTab. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1635 |
"/ selectedTab layout:selectedLayout. |
1401 | 1636 |
]. |
1637 |
! ! |
|
1638 |
||
1639 |
!NoteBookView methodsFor:'event handling'! |
|
1640 |
||
3181 | 1641 |
buttonMotion:buttonState x:x y:y |
3182 | 1642 |
|tab mustShowEntered| |
1643 |
||
1644 |
RemoveTabIcon notNil ifTrue:[ |
|
1645 |
tab := self tabContainingPointX:x y:y. |
|
1646 |
(tab notNil and:[tab == self selectedTab]) ifTrue:[ |
|
3185 | 1647 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
1648 |
mustShowEntered := (self destroyButtonFrameForTab:tab) containsPoint:(x@y). |
|
1649 |
mustShowEntered ~~ showingEnteredRemoveTabButton ifTrue:[ |
|
1650 |
showingEnteredRemoveTabButton := mustShowEntered. |
|
1651 |
self drawDestroyButtonForTab:tab. |
|
1652 |
] |
|
1653 |
]. |
|
3181 | 1654 |
]. |
1655 |
]. |
|
3185 | 1656 |
super buttonMotion:buttonState x:x y:y |
1657 |
||
1658 |
"Modified: / 01-03-2007 / 17:07:41 / cg" |
|
3181 | 1659 |
! |
1660 |
||
1401 | 1661 |
buttonPress:button x:x y:y |
2875 | 1662 |
"a button is pressed; find tab under point and set the selection" |
1663 |
||
1802 | 1664 |
|idx tab recv menu| |
1401 | 1665 |
|
3179 | 1666 |
tabWasActiveWhenPressed := false. |
1667 |
||
3207 | 1668 |
enabled ifFalse:[ ^ self ]. |
1669 |
self updateFocusIdOnSelectedTab. |
|
2279 | 1670 |
list isEmpty ifTrue:[ ^ self ]. |
1671 |
||
1672 |
idx := list findFirst:[:aTab| aTab containsPointX:x y:y ]. |
|
1673 |
idx == 0 ifTrue:[ ^ self ]. |
|
1674 |
tab := list at:idx. |
|
2875 | 1675 |
|
3179 | 1676 |
tabWasActiveWhenPressed := (tab == self selectedTab). |
1677 |
||
2279 | 1678 |
tab isEnabled ifFalse:[ ^ self ]. |
375 | 1679 |
|
2875 | 1680 |
((button ~~ 2) and:[button ~~ #menu]) ifTrue:[ |
1802 | 1681 |
"/ change the selection |
2875 | 1682 |
tab ~~ self selectedTab ifTrue:[ |
3336
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
1683 |
self userSelection:idx |
2875 | 1684 |
]. |
1685 |
^ self. |
|
1802 | 1686 |
]. |
2875 | 1687 |
|
2279 | 1688 |
accessTabMenuAction isNil ifTrue:[ ^ self ]. |
1689 |
menu := accessTabMenuAction value:idx. |
|
1690 |
menu isNil ifTrue:[ ^ self ]. |
|
1691 |
||
1802 | 1692 |
menu isArray ifTrue:[ |
1693 |
menu := menu decodeAsLiteralArray |
|
1694 |
]. |
|
1695 |
||
1696 |
menu receiver isNil ifTrue:[ |
|
1697 |
(recv := self application) isNil ifTrue:[ |
|
1698 |
recv := tab model |
|
1699 |
]. |
|
1700 |
recv notNil ifTrue:[ |
|
1701 |
menu receiver:recv |
|
1702 |
] ifFalse:[ |
|
2875 | 1703 |
Transcript showCR:('%1 : Menu has no receiver' bindWith:(self class name)). |
1401 | 1704 |
] |
1802 | 1705 |
]. |
2333 | 1706 |
self startUpMenu:menu |
1401 | 1707 |
! |
1708 |
||
2877 | 1709 |
buttonRelease:button x:x y:y |
1710 |
"a button is released; see if its the destroyTab button" |
|
3197 | 1711 |
|tab idx isDestroyAction| |
2877 | 1712 |
|
1713 |
enabled ifFalse:[ ^ self ]. |
|
1714 |
list isEmpty ifTrue:[ ^ self ]. |
|
1715 |
||
3197 | 1716 |
isDestroyAction := false. |
1717 |
||
3179 | 1718 |
tabWasActiveWhenPressed ifTrue:[ |
1719 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
|
1720 |
idx := list findFirst:[:aTab| aTab containsPointX:x y:y ]. |
|
3197 | 1721 |
tab := list at:idx ifAbsent:nil. |
1722 |
||
1723 |
tab notNil ifTrue:[ |
|
1724 |
( tab == self selectedTab |
|
1725 |
or:[self disableDestroyButtonOfInactiveTabs not] |
|
1726 |
) ifTrue:[ |
|
1727 |
((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[ |
|
1728 |
destroyTabAction value:idx. |
|
1729 |
isDestroyAction := true. |
|
1730 |
]. |
|
3179 | 1731 |
]. |
1732 |
]. |
|
2877 | 1733 |
]. |
1734 |
]. |
|
3197 | 1735 |
isDestroyAction ifFalse:[ |
1736 |
super buttonRelease:button x:x y:y. |
|
1737 |
]. |
|
1738 |
shown ifTrue:[ |
|
1739 |
self pushEvent:#updateFocusView. |
|
1740 |
]. |
|
2877 | 1741 |
! |
1742 |
||
1401 | 1743 |
keyPress:aKey x:x y:y |
1744 |
"selection might change; look for corresponding list entry |
|
1745 |
" |
|
1659 | 1746 |
<resource: #keyboard (#CursorRight #CursorLeft #CursorUp #CursorDown)> |
1407 | 1747 |
|
3510 | 1748 |
(enabled and:[(list size) ~~ 0]) ifFalse:[ |
1657
061c167ce3db
if disabled; call super keyPress:x:y to handle focusSequence
ca
parents:
1549
diff
changeset
|
1749 |
^ super keyPress:aKey x:x y:y |
1401 | 1750 |
]. |
1751 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1752 |
(self processAccessCharacter:aKey) ifTrue:[ |
1407 | 1753 |
^ self |
1754 |
]. |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1755 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1756 |
(self processShortcutKey:aKey) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1757 |
^ self |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1758 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1759 |
|
3510 | 1760 |
( aKey == #CursorRight |
1761 |
or:[ aKey == #CursorDown |
|
1762 |
or:[ aKey == #CursorLeft |
|
1763 |
or:[ aKey == #CursorUp]]] ) ifTrue:[ |
|
1764 |
self processCursorKey:aKey x:x y:y. |
|
1765 |
^ self |
|
2396
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1766 |
]. |
3510 | 1767 |
|
1768 |
^ super keyPress:aKey x:x y:y |
|
1401 | 1769 |
! |
1770 |
||
3181 | 1771 |
pointerLeave:state |
3183 | 1772 |
|tab| |
1773 |
||
3181 | 1774 |
showingEnteredRemoveTabButton ifTrue:[ |
1775 |
showingEnteredRemoveTabButton := false. |
|
3183 | 1776 |
tab := self selectedTab. |
1777 |
tab notNil ifTrue:[ |
|
1778 |
self drawDestroyButtonForTab:tab. |
|
1779 |
] |
|
3181 | 1780 |
]. |
1781 |
super pointerLeave:state |
|
1782 |
! |
|
1783 |
||
3510 | 1784 |
processCursorKey:aKey x:x y:y |
1785 |
"selection might change; look for corresponding list entry" |
|
1786 |
||
1787 |
<resource: #keyboard (#CursorRight #CursorLeft #CursorUp #CursorDown)> |
|
1788 |
||
1789 |
|sensor index nKeys selectNext selectPrev| |
|
1790 |
||
1791 |
selectNext := selectPrev := false. |
|
1792 |
||
1793 |
((aKey == #CursorRight) or:[aKey == #CursorDown]) ifTrue:[ |
|
1794 |
selectNext := true. |
|
1795 |
] ifFalse:[ ((aKey == #CursorLeft) or:[aKey == #CursorUp]) ifTrue:[ |
|
1796 |
selectPrev := true. |
|
1797 |
]]. |
|
1798 |
||
1799 |
"/ cg: this is rubbish - nobody needs key-compression here |
|
1800 |
"/ (if you fall asleep on the CursorRight key, you are not really |
|
1801 |
"/ doing useful work, anyway) !! |
|
1802 |
||
1803 |
sensor := self sensor. |
|
1804 |
sensor notNil ifTrue:[ |
|
1805 |
nKeys := 1 + (sensor compressKeyPressEventsWithKey:aKey). |
|
1806 |
nKeys := (nKeys \\ list size) max:1. |
|
1807 |
] ifFalse:[ |
|
1808 |
nKeys := 1. |
|
1809 |
]. |
|
1810 |
index := selection ? 0. |
|
1811 |
||
1812 |
nKeys timesRepeat:[ |
|
1813 |
selectNext ifTrue:[ |
|
3515 | 1814 |
index := self nextSelectableAfter:index wrapAtEnd:true. |
3510 | 1815 |
] ifFalse:[ |
3515 | 1816 |
index := self previousSelectableBefore:index wrapAtBegin:true. |
3510 | 1817 |
]. |
1818 |
index == 0 ifTrue:[^ self]. |
|
1819 |
]. |
|
1820 |
||
1821 |
self userSelection:index. |
|
1822 |
! |
|
1823 |
||
1677 | 1824 |
processShortcutKeyEvent:event |
1825 |
^ self processShortcutKey:(event key) |
|
1826 |
! |
|
1827 |
||
1401 | 1828 |
sizeChanged:how |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1829 |
"size of my view changed" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1830 |
|
1401 | 1831 |
super sizeChanged:how. |
1832 |
||
1833 |
list notEmpty ifTrue:[ |
|
1403 | 1834 |
lastComputedExtent ~= self extent ifTrue:[ |
1835 |
numberOfLines := nil. |
|
1836 |
] |
|
1680 | 1837 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1838 |
|
2905 | 1839 |
how ~~ #larger ifTrue:[ |
1840 |
self invalidate. |
|
1841 |
]. |
|
1680 | 1842 |
self resizeCanvas. |
1401 | 1843 |
! ! |
1844 |
||
1659 | 1845 |
!NoteBookView methodsFor:'focus handling'! |
1846 |
||
3186 | 1847 |
canTab |
1848 |
"if the list of tabLabels is empty, we do not need the focus |
|
1849 |
by tabing - give the focus to my included subviews." |
|
1850 |
||
3194 | 1851 |
^ list notEmpty and:[ super canTab ] |
1852 |
||
1853 |
"Modified: / 06-03-2007 / 16:55:01 / cg" |
|
3177 | 1854 |
! |
1855 |
||
1659 | 1856 |
showFocus:explicit |
2762 | 1857 |
"got the keyboard focus" |
1659 | 1858 |
|
2279 | 1859 |
self supportsFocusOnTab ifTrue:[ |
2762 | 1860 |
self invalidateSelectedTab |
1659 | 1861 |
] ifFalse:[ |
1862 |
super showFocus:explicit |
|
3177 | 1863 |
]. |
1659 | 1864 |
! |
1865 |
||
1866 |
showNoFocus:explicit |
|
2762 | 1867 |
"lost the keyboard focus" |
1659 | 1868 |
|
2279 | 1869 |
self supportsFocusOnTab ifTrue:[ |
2762 | 1870 |
self invalidateSelectedTab |
1659 | 1871 |
] ifFalse:[ |
1872 |
super showNoFocus:explicit |
|
3177 | 1873 |
]. |
2279 | 1874 |
! |
1875 |
||
1876 |
supportsFocusOnTab |
|
3510 | 1877 |
"return true if the keyboard focus can ever be on the tab area |
2279 | 1878 |
" |
1879 |
^ (styleSheet at:#'focusHighlightStyle') == #win95 |
|
3197 | 1880 |
! |
1881 |
||
3207 | 1882 |
updateFocusIdOnSelectedTab |
1883 |
"update the lastFocusId for the current selected tab" |
|
1884 |
||
1885 |
|tab focusView id| |
|
1886 |
||
1887 |
(canvas notNil and:[canvas shown]) ifFalse:[^ self]. |
|
3269 | 1888 |
windowGroup isNil ifTrue:[^ self]. |
3207 | 1889 |
|
1890 |
focusView := windowGroup focusView. |
|
1891 |
(focusView notNil and:[focusView shown]) ifFalse:[^ self ]. |
|
1892 |
||
1893 |
tab := self selectedTab. |
|
1894 |
tab isNil ifTrue:[^ self]. |
|
1895 |
||
1896 |
id := focusView id. |
|
1897 |
tab lastFocusViewId = id ifTrue:[^ self]. |
|
1898 |
||
1899 |
(focusView isComponentOf:canvas) ifTrue:[ |
|
1900 |
tab lastFocusViewId:id. |
|
1901 |
]. |
|
3269 | 1902 |
|
1903 |
"Modified: / 05-11-2007 / 14:22:57 / cg" |
|
3207 | 1904 |
! |
1905 |
||
3197 | 1906 |
updateFocusView |
3207 | 1907 |
"called when updating the focusView within my canvas" |
1908 |
||
1909 |
|focusView tab id keyBoardConsumer alternateFocusView toolbarFocusView| |
|
1910 |
||
1911 |
(canvas notNil and:[canvas shown]) ifFalse:[ ^ self ]. |
|
1912 |
||
1913 |
tab := self selectedTab. |
|
3269 | 1914 |
windowGroup notNil ifTrue:[ |
1915 |
focusView := windowGroup focusView. |
|
1916 |
]. |
|
3207 | 1917 |
(focusView notNil and:[focusView shown]) ifTrue:[ |
1918 |
(focusView isComponentOf:canvas) ifTrue:[ |
|
1919 |
tab notNil ifTrue:[ |
|
1920 |
tab lastFocusViewId:(focusView id). |
|
1921 |
]. |
|
1922 |
^ self |
|
1923 |
]. |
|
3197 | 1924 |
]. |
3207 | 1925 |
|
1926 |
tab notNil ifTrue:[ |
|
1927 |
(id := tab lastFocusViewId) notNil ifTrue:[ |
|
1928 |
"/ show if last stored view with id within canvas exists |
|
1929 |
focusView := canvas allSubViewsDetect:[:v| v id = id ] ifNone:nil. |
|
1930 |
||
1931 |
(focusView notNil and:[focusView shown]) ifTrue:[ |
|
1932 |
windowGroup focusView:focusView byTab:true. |
|
1933 |
^ self |
|
1934 |
]. |
|
1935 |
tab lastFocusViewId:nil. |
|
3197 | 1936 |
]. |
1937 |
]. |
|
1938 |
||
1939 |
canvas focusNextForWhich:[:aView| |
|
1940 |
aView shown ifTrue:[ |
|
1941 |
aView isKeyboardConsumer ifTrue:[ |
|
1942 |
keyBoardConsumer := aView. |
|
1943 |
] ifFalse:[ |
|
1944 |
alternateFocusView isNil ifTrue:[ |
|
1945 |
(aView isMemberOf:MenuPanel) ifTrue:[ |
|
1946 |
toolbarFocusView notNil ifTrue:[ |
|
1947 |
toolbarFocusView := aView. |
|
1948 |
] |
|
1949 |
] ifFalse:[ |
|
1950 |
alternateFocusView := aView |
|
1951 |
]. |
|
1952 |
]. |
|
1953 |
]. |
|
1954 |
]. |
|
1955 |
keyBoardConsumer notNil |
|
1956 |
]. |
|
1957 |
focusView := keyBoardConsumer ? alternateFocusView. |
|
1958 |
||
1959 |
focusView isNil ifTrue:[ |
|
1960 |
toolbarFocusView isNil ifTrue:[^ self]. |
|
1961 |
focusView := toolbarFocusView. |
|
1962 |
]. |
|
3207 | 1963 |
tab notNil ifTrue:[ |
1964 |
tab lastFocusViewId:(focusView id) |
|
1965 |
]. |
|
1966 |
windowGroup focusView:focusView byTab:true. |
|
3269 | 1967 |
|
1968 |
"Modified: / 05-11-2007 / 14:24:23 / cg" |
|
3197 | 1969 |
! |
1970 |
||
1971 |
wantsFocusWithButtonPress |
|
1972 |
"never wants the focus by button press |
|
1973 |
" |
|
1974 |
^ false |
|
1659 | 1975 |
! ! |
1976 |
||
1759 | 1977 |
!NoteBookView methodsFor:'help'! |
1978 |
||
2877 | 1979 |
flyByHelpTextAt:srcPoint |
1980 |
^ self helpTextAt:srcPoint |
|
1981 |
! |
|
1982 |
||
1759 | 1983 |
helpText |
2877 | 1984 |
"return the helpText for the currently selected item (empty if none)" |
1985 |
||
1759 | 1986 |
^ self helpTextForItemAt:selection |
1987 |
! |
|
1988 |
||
1989 |
helpTextAt:srcPoint |
|
2877 | 1990 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)." |
1991 |
||
3179 | 1992 |
|x y tab| |
1759 | 1993 |
|
1994 |
x := srcPoint x. |
|
1995 |
y := srcPoint y. |
|
3179 | 1996 |
tab := self tabContainingPointX:x y:y. |
1997 |
||
1998 |
tab notNil ifTrue:[ |
|
2877 | 1999 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
3179 | 2000 |
(tab == self selectedTab |
2001 |
or:[ self disableDestroyButtonOfInactiveTabs not ]) ifTrue:[ |
|
2002 |
((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[ |
|
2003 |
^ resources string:'Remove this Tab' |
|
2004 |
] |
|
2877 | 2005 |
]. |
2006 |
]. |
|
2007 |
]. |
|
3179 | 2008 |
|
2009 |
^ self helpTextForTab:tab |
|
1759 | 2010 |
! |
2011 |
||
2012 |
helpTextForItemAt:anIndex |
|
3179 | 2013 |
|tab| |
1759 | 2014 |
|
2015 |
( anIndex notNil |
|
2016 |
and:[anIndex ~~ 0 |
|
3179 | 2017 |
and:[(tab := list at:anIndex ifAbsent:nil) notNil]] |
1759 | 2018 |
) ifTrue:[ |
3179 | 2019 |
^ self helpTextForTab:tab. |
2020 |
]. |
|
2021 |
^ nil |
|
2022 |
||
2023 |
"Modified: / 06-09-2006 / 16:03:03 / cg" |
|
2024 |
! |
|
2025 |
||
2026 |
helpTextForTab:aTab |
|
2027 |
|tabItem| |
|
2028 |
||
2029 |
aTab notNil ifTrue:[ |
|
2030 |
(tabItem := aTab tabItem) notNil ifTrue:[ |
|
2031 |
^ tabItem activeHelpText |
|
2032 |
]. |
|
1759 | 2033 |
]. |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2034 |
^ nil |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2035 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2036 |
"Modified: / 06-09-2006 / 16:03:03 / cg" |
1759 | 2037 |
! ! |
2038 |
||
1687 | 2039 |
!NoteBookView methodsFor:'initialization & release'! |
1401 | 2040 |
|
2041 |
destroy |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2042 |
"remove dependencies" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2043 |
|
1401 | 2044 |
list removeDependent:self. |
2045 |
||
2046 |
listHolder removeDependent:self. |
|
2047 |
canvasHolder removeDependent:self. |
|
2048 |
||
2723 | 2049 |
list notEmptyOrNil ifTrue:[ |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2050 |
list do:[:anItem| |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2051 |
|tabItem| |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2052 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2053 |
tabItem := anItem tabItem. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2054 |
tabItem notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2055 |
tabItem destroyCanvas. |
2723 | 2056 |
] |
2057 |
] |
|
2058 |
]. |
|
1401 | 2059 |
super destroy. |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2060 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
2061 |
"Modified: / 06-09-2006 / 16:04:32 / cg" |
1401 | 2062 |
! |
2063 |
||
2064 |
initStyle |
|
2065 |
"setup style attributes |
|
2066 |
" |
|
2922 | 2067 |
<resource: #style (#'noteBook.viewBackground' |
2068 |
)> |
|
1442 | 2069 |
|clr| |
2070 |
||
1401 | 2071 |
super initStyle. |
1682 | 2072 |
tabModus := false. |
2073 |
edgeStyle := DefaultEdgeStyle. |
|
1442 | 2074 |
|
2760 | 2075 |
clr := styleSheet colorAt:#'noteBook.viewBackground'. |
2076 |
clr notNil ifTrue:[ viewBackground := clr ]. |
|
2077 |
||
1401 | 2078 |
self font:self class defaultFont. |
1682 | 2079 |
drawLightColor := Color veryLightGray onDevice:device. |
1442 | 2080 |
|
1682 | 2081 |
clr := DefaultForegroundColor ? Black. |
2082 |
foregroundColor := clr onDevice:device. |
|
2083 |
||
2760 | 2084 |
clr := DefaultBackgroundColor ? viewBackground. |
2085 |
backgroundColor := clr onDevice:device. |
|
2086 |
||
2087 |
clr := DefaultActiveBackgroundColor ? backgroundColor. |
|
2088 |
activeBackgroundColor := clr onDevice:device. |
|
2089 |
||
2090 |
clr := DefaultActiveForegroundColor ? foregroundColor. |
|
1682 | 2091 |
activeForegroundColor := clr onDevice:device. |
2092 |
||
2292 | 2093 |
"/ (clr := DefaultShadowColor) isNil ifTrue:[clr := viewBackground darkened]. |
2094 |
"/ shadowColor := clr onDevice:device. |
|
2095 |
"/ (clr := DefaultLightColor) isNil ifTrue:[clr := viewBackground lightened]. |
|
2096 |
"/ lightColor := clr onDevice:device. |
|
2097 |
||
2098 |
(clr := DefaultShadowColor) notNil ifTrue:[shadowColor := clr onDevice:device]. |
|
2099 |
(clr := DefaultLightColor) notNil ifTrue:[lightColor := clr onDevice:device]. |
|
1689
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
2100 |
|
1682 | 2101 |
edgeStyle isNil ifTrue:[ |
2102 |
halfShadowColor := shadowColor. |
|
2103 |
halfLightColor := lightColor. |
|
2104 |
drawLightColor := lightColor. |
|
2105 |
] ifFalse:[ |
|
2292 | 2106 |
"/ (clr := DefaultHalfShadowColor) isNil ifTrue:[ |
2107 |
"/ clr := shadowColor lightened |
|
2108 |
"/ ]. |
|
2109 |
"/ halfShadowColor := clr onDevice:device. |
|
2110 |
"/ |
|
2111 |
"/ (clr := DefaultHalfLightColor) isNil ifTrue:[ |
|
2112 |
"/ clr := lightColor darkened. |
|
2113 |
"/ ]. |
|
2114 |
"/ halfLightColor := clr onDevice:device. |
|
2115 |
||
2116 |
(clr := DefaultHalfShadowColor) notNil ifTrue:[ |
|
2117 |
halfShadowColor := clr onDevice:device. |
|
1442 | 2118 |
]. |
2292 | 2119 |
|
2120 |
(clr := DefaultHalfLightColor) notNil ifTrue:[ |
|
2121 |
halfLightColor := clr onDevice:device. |
|
1682 | 2122 |
]. |
2123 |
||
2124 |
edgeStyle == #soft ifTrue:[ |
|
2125 |
drawLightColor := halfShadowColor |
|
2126 |
] ifFalse:[ |
|
2127 |
drawLightColor := Color veryLightGray onDevice:device. |
|
2128 |
] |
|
1442 | 2129 |
]. |
1700 | 2130 |
(clr := DisabledForegroundColor) notNil ifTrue:[ |
2131 |
disabledForegroundColor := clr onDevice:device |
|
2132 |
]ifFalse:[ |
|
2133 |
disabledForegroundColor := drawLightColor |
|
2134 |
]. |
|
2882 | 2135 |
|
2136 |
activeTabMarkerColor := DefaultActiveTabMarkerColor. |
|
2137 |
activeTabMarkerFGColor := DefaultActiveTabMarkerFgColor. |
|
1401 | 2138 |
! |
2139 |
||
2140 |
initialize |
|
2746
2c614cc1559c
Do not hardcode noteBook.tabTobMargin for windows
Stefan Vogel <sv@exept.de>
parents:
2740
diff
changeset
|
2141 |
|
1401 | 2142 |
super initialize. |
2143 |
||
2877 | 2144 |
self enableMotionEvents. "/ for flyByHelp |
1401 | 2145 |
self cursor:Cursor hand. |
2146 |
||
1680 | 2147 |
list := #(). |
2148 |
useIndex := true. |
|
2149 |
direction := #top. |
|
2150 |
fitLastRow := true. |
|
2151 |
enabled := true. |
|
2875 | 2152 |
showDestroyTabButton := false. |
2882 | 2153 |
canvasInset := styleSheet at:#'noteBook.canvasInset' default:1@1. |
1680 | 2154 |
keepCanvas := false. |
2882 | 2155 |
tabLevel := styleSheet at:#'noteBook.tabLevel' default:1. |
2156 |
tabLabelInset := styleSheet at:#'noteBook.tabLabelInset' default:6@4. |
|
2280 | 2157 |
selectionInsetX := (2 max:(tabLevel abs)) + 1. |
2158 |
selectionInsetY := (2 max:(tabLevel abs)) + 1. |
|
2629 | 2159 |
translateLabel := false. |
2285 | 2160 |
|
2691 | 2161 |
tabRightMargin := 0. |
2162 |
tabLeftMargin := 0. |
|
2163 |
||
2882 | 2164 |
tabTopMargin := styleSheet at:#'noteBook.tabTopMargin' default:4. |
2165 |
tabBottomMargin := styleSheet at:#'noteBook.tabBottomMargin' default:1. |
|
2280 | 2166 |
|
3181 | 2167 |
showingEnteredRemoveTabButton := false. |
2168 |
tabWasActiveWhenPressed := false. |
|
2169 |
||
1401 | 2170 |
self lineWidth:0. |
2171 |
||
2529 | 2172 |
"/ canvas notNil ifTrue:[ |
2173 |
"/ canvas := canvas in:self. |
|
2174 |
"/ ]. |
|
1403 | 2175 |
! |
2176 |
||
2682 | 2177 |
mapped |
2178 |
||
2179 |
super mapped. |
|
2691 | 2180 |
|
2682 | 2181 |
canvas notNil ifTrue:[ |
3197 | 2182 |
canvas beVisible. |
2183 |
canvas raise. |
|
2184 |
self hasFocus ifTrue:[ |
|
2185 |
self pushEvent:#updateFocusView. |
|
2186 |
]. |
|
2682 | 2187 |
]. |
2188 |
! |
|
2189 |
||
2739 | 2190 |
postRealize |
2191 |
"automatically set the initially selected notebook tab; |
|
2192 |
unless it has been set already (by setup code)" |
|
2193 |
||
2194 |
selection isNil ifTrue:[ |
|
2195 |
self setSelection:1. |
|
2196 |
]. |
|
2197 |
super postRealize. |
|
2198 |
! |
|
2199 |
||
1403 | 2200 |
realize |
2201 |
||
2202 |
(canvas notNil and:[numberOfLines isNil]) ifTrue:[ |
|
2203 |
self recomputeList |
|
2204 |
]. |
|
2205 |
super realize. |
|
1401 | 2206 |
! ! |
2207 |
||
2208 |
!NoteBookView methodsFor:'layout'! |
|
2209 |
||
2210 |
computeBorderLayout |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2211 |
"returns the layout of the frame araound the canvas" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2212 |
|
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
2213 |
|xL yT xR yB tab l| |
1401 | 2214 |
|
2215 |
xL := 0. |
|
2216 |
yT := 0. |
|
2691 | 2217 |
xR := self width. |
2218 |
yB := self height. |
|
1401 | 2219 |
|
2278 | 2220 |
list notEmpty ifTrue:[ |
2221 |
tab := list detect:[:aTab| aTab lineNr == 1] ifNone:nil. |
|
2222 |
||
2223 |
tab notNil ifTrue:[ |
|
2896 | 2224 |
l := tab unselectedLayout. |
2278 | 2225 |
|
2279 | 2226 |
direction == #top ifTrue:[ yT := l bottom ] |
2227 |
ifFalse:[ direction == #bottom ifTrue:[ yB := l top ] |
|
2228 |
ifFalse:[ direction == #left ifTrue:[ xL := l right ] |
|
2229 |
ifFalse:[ |
|
2278 | 2230 |
xR := l left |
2231 |
]]] |
|
2232 |
] |
|
1401 | 2233 |
]. |
2686 | 2234 |
self buttonLayoutUpdate. |
2235 |
||
1401 | 2236 |
^ Rectangle left:xL top:yT right:xR bottom:yB |
2237 |
! |
|
2238 |
||
2239 |
computeLayoutForTab:aTab |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2240 |
"calculate the effective bounds of a tab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2241 |
This includes any size changes for the active tab (overlap etc.)." |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2242 |
|
3179 | 2243 |
|unselectedLayout selectedLayout computedLayout bwAbs |
2244 |
tabLeft tabRight tabTop tabBottom| |
|
1401 | 2245 |
|
2687 | 2246 |
aTab isNil ifTrue:[^ nil]. |
2247 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2248 |
unselectedLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2249 |
(self hasTabSelected:aTab) ifFalse:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2250 |
^ unselectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2251 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2252 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2253 |
selectedLayout := aTab selectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2254 |
selectedLayout notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2255 |
^ selectedLayout |
1658 | 2256 |
]. |
1401 | 2257 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2258 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2259 |
"/ compute and remember |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2260 |
bwAbs := tabLevel abs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2261 |
tabLeft := unselectedLayout left. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2262 |
tabRight := unselectedLayout right. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2263 |
tabTop := unselectedLayout top. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2264 |
tabBottom := unselectedLayout bottom. |
1658 | 2265 |
|
2266 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2267 |
tabLeft := tabLeft - selectionInsetX. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2268 |
tabRight := tabRight + selectionInsetX. |
2686 | 2269 |
|
2289 | 2270 |
bwAbs == 0 ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2271 |
tabLeft == 0 ifTrue:[ tabLeft := tabLeft - 1 ]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2272 |
tabRight == self width ifTrue:[ tabRight := tabRight + 1 ]. |
2289 | 2273 |
]. |
2283 | 2274 |
|
2278 | 2275 |
direction == #top ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2276 |
tabBottom := tabBottom + bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2277 |
tabTop := tabTop - selectionInsetY. |
375 | 2278 |
] ifFalse:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2279 |
tabTop := tabTop - bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2280 |
tabBottom := tabBottom + selectionInsetY. |
1658 | 2281 |
]. |
2278 | 2282 |
] ifFalse:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2283 |
tabTop := tabTop - selectionInsetX. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2284 |
tabBottom := tabBottom + selectionInsetX. |
2686 | 2285 |
|
2289 | 2286 |
bwAbs == 0 ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2287 |
tabTop == 0 ifTrue:[ tabTop := tabTop - 1 ]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2288 |
tabBottom == self height ifTrue:[ tabBottom := tabBottom + 1 ]. |
2289 | 2289 |
]. |
2278 | 2290 |
|
2291 |
direction == #left ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2292 |
tabRight := tabRight + bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2293 |
tabLeft := tabLeft - selectionInsetY |
2278 | 2294 |
] ifFalse:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2295 |
tabLeft := tabLeft - bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2296 |
tabRight := tabRight + selectionInsetY. |
2278 | 2297 |
] |
1401 | 2298 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2299 |
computedLayout := Rectangle left:tabLeft top:tabTop right:tabRight bottom:tabBottom. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2300 |
aTab selectedLayout:computedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2301 |
^ computedLayout |
1401 | 2302 |
! |
2303 |
||
2304 |
makeToBaseLine:aLnNr |
|
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2305 |
"rotate lines to make the line #aLnNr be the new base line (i.e. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2306 |
subtract (aLnNr-1) from all lines and take modulu the number of lines" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2307 |
|
1963 | 2308 |
|lineTopsOrLefts isHorizontal| |
2309 |
||
2310 |
isHorizontal := self isHorizontal. |
|
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2311 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2312 |
"collect per-lineNr offsets" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2313 |
lineTopsOrLefts := (1 to:numberOfLines) collect:[:lnr | |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2314 |
|tabNr layout| |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2315 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2316 |
tabNr := list findFirst:[:aTab| aTab lineNr == lnr]. |
2896 | 2317 |
layout := (list at:tabNr) unselectedLayout. |
1963 | 2318 |
isHorizontal ifTrue:[ |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2319 |
layout top. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2320 |
] ifFalse:[ |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2321 |
layout left. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2322 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2323 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2324 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2325 |
"change offsets of all tabs" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2326 |
list do:[:el | |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2327 |
|layout topOrLeft nr newNr| |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2328 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2329 |
nr := el lineNr. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2330 |
newNr := nr - aLnNr + 1. |
1964 | 2331 |
newNr <= 0 ifTrue:[ newNr := newNr + numberOfLines]. |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2332 |
newNr := ((newNr - 1) \\ numberOfLines) + 1. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2333 |
topOrLeft := lineTopsOrLefts at:newNr. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2334 |
|
2896 | 2335 |
layout := el unselectedLayout copy. |
1963 | 2336 |
isHorizontal ifTrue:[ |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2337 |
layout setTop:topOrLeft. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2338 |
] ifFalse:[ |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2339 |
layout setLeft:topOrLeft. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2340 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2341 |
el unselectedLayout:layout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2342 |
el selectedLayout:nil. |
2896 | 2343 |
el layout:(self computeLayoutForTab:el). |
2344 |
||
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2345 |
el lineNr:newNr. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2346 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2347 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2348 |
self invalidate. |
1401 | 2349 |
! |
2350 |
||
2351 |
recomputeList |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2352 |
"recompute list" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2353 |
|
2686 | 2354 |
|tab| |
2355 |
||
2281 | 2356 |
numberOfLines := 1. |
1403 | 2357 |
lastComputedExtent := self extent. |
1401 | 2358 |
|
2686 | 2359 |
self transformation:nil. |
2360 |
||
1680 | 2361 |
list size ~~ 0 ifTrue:[ |
2281 | 2362 |
self isHorizontal ifTrue:[ self recomputeListHorizontal ] |
2686 | 2363 |
ifFalse:[ self recomputeListVertical ]. |
2364 |
||
2365 |
tab := self selectedTab. |
|
2366 |
tab isNil ifTrue:[tab := list first]. |
|
2893 | 2367 |
tab layout:(self computeLayoutForTab:tab). |
1401 | 2368 |
]. |
2725 | 2369 |
self validateVisibleCanvas. |
1680 | 2370 |
self resizeCanvas. |
2686 | 2371 |
|
2372 |
self hasScrollButtons ifTrue:[ |
|
2373 |
self isHorizontal ifTrue:[ |
|
2374 |
buttonNext direction:#right. |
|
2375 |
buttonPrev direction:#left. |
|
2376 |
] ifFalse:[ |
|
2377 |
buttonNext direction:#down. |
|
2378 |
buttonPrev direction:#up. |
|
2379 |
]. |
|
2380 |
self makeVisible:tab. |
|
2381 |
]. |
|
1401 | 2382 |
! |
2383 |
||
2384 |
recomputeListHorizontal |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2385 |
"compute layouts for all tabs" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2386 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2387 |
|lastLyt tabExtent isScrollable |
2691 | 2388 |
xLeft "{ Class:SmallInteger }" |
2389 |
xRight "{ Class:SmallInteger }" |
|
2390 |
yTop "{ Class:SmallInteger }" |
|
2391 |
tabWidth "{ Class:SmallInteger }" |
|
2392 |
tabHeight "{ Class:SmallInteger }" |
|
2393 |
delta "{ Class:SmallInteger }" |
|
2394 |
first "{ Class:SmallInteger }" |
|
2395 |
border "{ Class:SmallInteger }" |
|
2396 |
lastLnNr "{ Class:SmallInteger }" |
|
2397 |
tabLvlAbs "{ Class:SmallInteger }" |
|
2398 |
minLeft "{ Class:SmallInteger }" |
|
2399 |
maxRight "{ Class:SmallInteger }" |
|
2400 |
leftMargin "{ Class:SmallInteger }" |
|
2401 |
rightMargin "{ Class:SmallInteger }" |
|
1401 | 2402 |
| |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2403 |
|
2283 | 2404 |
tabLvlAbs := tabLevel abs max:1. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2405 |
border := tabLvlAbs * 2. |
2281 | 2406 |
tabHeight := 0. |
2691 | 2407 |
leftMargin := self tabLeftMargin. |
2408 |
rightMargin := self tabRightMargin. |
|
2409 |
minLeft := leftMargin + selectionInsetX. |
|
2410 |
maxRight := self width - rightMargin - selectionInsetX. |
|
2286 | 2411 |
xLeft := minLeft. |
2686 | 2412 |
isScrollable := self hasScrollButtons. |
1401 | 2413 |
|
2414 |
list do:[:aTab| |
|
2431 | 2415 |
tabExtent := self preferredExtentForTab:aTab. |
2416 |
tabWidth := tabExtent x + border. |
|
2417 |
tabHeight := tabExtent y max:tabHeight. |
|
2281 | 2418 |
xRight := xLeft + tabWidth. |
1401 | 2419 |
|
2686 | 2420 |
(isScrollable not and:[xRight > maxRight]) ifTrue:[ |
2286 | 2421 |
xLeft ~~ minLeft ifTrue:[ |
2281 | 2422 |
numberOfLines := numberOfLines + 1. |
2286 | 2423 |
xLeft := minLeft. |
2281 | 2424 |
xRight := xLeft + tabWidth. |
2425 |
]. |
|
2286 | 2426 |
xRight > maxRight ifTrue:[ |
2427 |
tabWidth := maxRight - minLeft. |
|
2428 |
xRight := maxRight. |
|
2281 | 2429 |
]. |
1401 | 2430 |
]. |
2431 |
aTab lineNr:numberOfLines. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2432 |
aTab unselectedLayout:(Rectangle left:xLeft top:0 width:tabWidth height:tabHeight). |
2281 | 2433 |
xLeft := xRight. |
1401 | 2434 |
]. |
2283 | 2435 |
tabHeight := tabHeight + tabLvlAbs. |
2436 |
yTop := selectionInsetY + tabTopMargin. |
|
2281 | 2437 |
|
2438 |
direction == #bottom ifTrue:[ |
|
2691 | 2439 |
yTop := self height - tabHeight - yTop. |
2281 | 2440 |
delta := tabHeight negated. |
2441 |
] ifFalse:[ |
|
2442 |
delta := tabHeight |
|
2443 |
]. |
|
2444 |
||
2445 |
lastLnNr := numberOfLines. |
|
1401 | 2446 |
|
2281 | 2447 |
list reverseDo:[:aTab| |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2448 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2449 |
|
2281 | 2450 |
aTab lineNr ~~ lastLnNr ifTrue:[ |
2451 |
lastLnNr := aTab lineNr. |
|
2452 |
yTop := yTop + delta |
|
2453 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2454 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2455 |
tabLayout setTop:yTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2456 |
tabLayout height:tabHeight. |
1401 | 2457 |
]. |
2281 | 2458 |
|
1401 | 2459 |
tabModus ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2460 |
|firstTabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2461 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2462 |
firstTabLayout := list first unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2463 |
delta := direction == #top |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2464 |
ifTrue:[self height - firstTabLayout bottom] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2465 |
ifFalse:[firstTabLayout top negated]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2466 |
|
2894 | 2467 |
list do:[:aTab | |l| |
2468 |
l := aTab unselectedLayout. |
|
2469 |
l setTop:(l top + delta). |
|
2470 |
]. |
|
1401 | 2471 |
]. |
2472 |
||
2473 |
"/ FIT LINES |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2474 |
(numberOfLines ~~ 1 or:[fitLastRow]) ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2475 |
first := 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2476 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2477 |
1 to:numberOfLines do:[:aLnNr| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2478 |
|last| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2479 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2480 |
last := list findLast:[:t|t lineNr == aLnNr]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2481 |
lastLyt := (list at:last) unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2482 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2483 |
(delta := maxRight - lastLyt right) > 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2484 |
xLeft := minLeft. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2485 |
delta := delta // (last - first + 1). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2486 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2487 |
delta ~~ 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2488 |
list from:first to:last do:[:aTab| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2489 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2490 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2491 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2492 |
tabWidth := tabLayout width + delta. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2493 |
tabLayout setLeft:xLeft. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2494 |
tabLayout width:tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2495 |
xLeft := xLeft + tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2496 |
] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2497 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2498 |
lastLyt width:(maxRight - lastLyt left) |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2499 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2500 |
first := last + 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2501 |
] |
1401 | 2502 |
]. |
2503 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2504 |
list do:[:aTab | aTab layout:aTab unselectedLayout; selectedLayout:nil ]. |
1401 | 2505 |
! |
2506 |
||
2507 |
recomputeListVertical |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2508 |
"compute layouts for all tabs" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2509 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2510 |
|lastLyt tabExtent isScrollable |
2691 | 2511 |
xTop "{ Class:SmallInteger }" |
2512 |
yTop "{ Class:SmallInteger }" |
|
2513 |
yBottom "{ Class:SmallInteger }" |
|
2514 |
tabWidth "{ Class:SmallInteger }" |
|
2515 |
tabHeight "{ Class:SmallInteger }" |
|
2516 |
delta "{ Class:SmallInteger }" |
|
2517 |
first "{ Class:SmallInteger }" |
|
2518 |
border "{ Class:SmallInteger }" |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2519 |
lastLnNr "{ Class:SmallInteger }" |
2691 | 2520 |
tabLvlAbs "{ Class:SmallInteger }" |
2521 |
minTop "{ Class:SmallInteger }" |
|
2522 |
maxBottom "{ Class:SmallInteger }" |
|
2523 |
leftMargin "{ Class:SmallInteger }" |
|
2524 |
rightMargin "{ Class:SmallInteger }" |
|
1401 | 2525 |
| |
2010 | 2526 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2527 |
tabLvlAbs := tabLevel abs max:1. |
2283 | 2528 |
border := tabLvlAbs * 2. |
2281 | 2529 |
tabHeight := 0. |
2691 | 2530 |
leftMargin := self tabLeftMargin. |
2531 |
rightMargin := self tabRightMargin. |
|
2532 |
minTop := leftMargin + selectionInsetX. |
|
2533 |
maxBottom := self height - rightMargin - selectionInsetX. |
|
2286 | 2534 |
yTop := minTop. |
2686 | 2535 |
isScrollable := self hasScrollButtons. |
1401 | 2536 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2537 |
list do:[:aTab| aTab layout:nil; unselectedLayout:nil; selectedLayout:nil]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2538 |
|
1401 | 2539 |
list do:[:aTab| |
2431 | 2540 |
tabExtent := self preferredExtentForTab:aTab. |
2541 |
tabWidth := tabExtent x + border. |
|
2542 |
tabHeight := tabExtent y max:tabHeight. |
|
2281 | 2543 |
yBottom := yTop + tabWidth. |
1401 | 2544 |
|
2686 | 2545 |
(isScrollable not and:[yBottom > maxBottom]) ifTrue:[ |
2286 | 2546 |
yTop ~~ minTop ifTrue:[ |
2281 | 2547 |
numberOfLines := numberOfLines + 1. |
2286 | 2548 |
yTop := minTop. |
2281 | 2549 |
yBottom := yTop + tabWidth. |
2550 |
]. |
|
2286 | 2551 |
yBottom > maxBottom ifTrue:[ |
2552 |
tabWidth := maxBottom - minTop. |
|
2553 |
yBottom := maxBottom. |
|
2281 | 2554 |
]. |
1401 | 2555 |
]. |
2556 |
aTab lineNr:numberOfLines. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2557 |
aTab unselectedLayout:(Rectangle left:0 top:yTop width:tabHeight height:tabWidth). |
2281 | 2558 |
yTop := yBottom |
1401 | 2559 |
]. |
2283 | 2560 |
tabHeight := tabHeight + tabLvlAbs. |
2561 |
xTop := selectionInsetY + tabTopMargin. |
|
2281 | 2562 |
|
2563 |
direction == #right ifTrue:[ |
|
2691 | 2564 |
xTop := self width - tabHeight - xTop. |
2281 | 2565 |
delta := tabHeight negated. |
2566 |
] ifFalse:[ |
|
2567 |
delta := tabHeight. |
|
2568 |
]. |
|
1401 | 2569 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2570 |
lastLnNr := numberOfLines. |
2281 | 2571 |
|
2572 |
list reverseDo:[:aTab| |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2573 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2574 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2575 |
aTab lineNr ~~ lastLnNr ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2576 |
lastLnNr := aTab lineNr. |
2281 | 2577 |
xTop := xTop + delta |
2578 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2579 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2580 |
tabLayout setLeft:xTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2581 |
tabLayout width:tabHeight. |
1401 | 2582 |
]. |
2281 | 2583 |
|
1401 | 2584 |
tabModus ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2585 |
|firstTabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2586 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2587 |
firstTabLayout := list first unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2588 |
delta := direction == #left |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2589 |
ifTrue:[self width - firstTabLayout right] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2590 |
ifFalse:[firstTabLayout left negated]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2591 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2592 |
list do:[:aTab | |l| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2593 |
l := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2594 |
l setLeft:(l left + delta). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2595 |
]. |
1401 | 2596 |
]. |
2597 |
||
2598 |
"/ FIT LINES |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2599 |
(numberOfLines ~~ 1 or:[fitLastRow]) ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2600 |
first := 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2601 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2602 |
1 to:numberOfLines do:[:aLnNr| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2603 |
|last| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2604 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2605 |
last := list findLast:[:t|t lineNr == aLnNr]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2606 |
lastLyt := (list at:last) unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2607 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2608 |
(delta := maxBottom - lastLyt bottom) > 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2609 |
yTop := minTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2610 |
delta := delta // (last - first + 1). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2611 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2612 |
delta ~~ 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2613 |
list from:first to:last do:[:aTab| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2614 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2615 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2616 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2617 |
tabWidth := tabLayout height + delta. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2618 |
tabLayout setTop:yTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2619 |
tabLayout height:tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2620 |
yTop := yTop + tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2621 |
] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2622 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2623 |
lastLyt height:(maxBottom - lastLyt top) |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2624 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2625 |
first := last + 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2626 |
]. |
1401 | 2627 |
]. |
2628 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2629 |
list do:[:aTab | aTab layout:aTab unselectedLayout; selectedLayout:nil ]. |
1680 | 2630 |
! |
2631 |
||
2632 |
resizeCanvas |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2633 |
|newLayout borderWd| |
1680 | 2634 |
|
2635 |
canvas notNil ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2636 |
newLayout := self computeBorderLayout. |
2278 | 2637 |
|
2638 |
list notEmpty ifTrue:[ |
|
2639 |
borderWd := tabLevel abs. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2640 |
newLayout := newLayout insetBy:(canvasInset + borderWd). |
2284 | 2641 |
|
2642 |
tabBottomMargin > 0 ifTrue:[ |
|
2643 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2644 |
newLayout height:(newLayout height - tabBottomMargin). |
2284 | 2645 |
direction == #top ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2646 |
newLayout setTop:(newLayout top + tabBottomMargin) |
2284 | 2647 |
] |
2648 |
] ifFalse:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2649 |
newLayout width:(newLayout width - tabBottomMargin). |
2284 | 2650 |
|
2651 |
direction == #left ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2652 |
newLayout setLeft:(newLayout left + tabBottomMargin) |
2284 | 2653 |
] |
2654 |
] |
|
2655 |
||
2656 |
]. |
|
2036 | 2657 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2658 |
newLayout ~= canvas layout ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2659 |
canvas layout:newLayout. |
2278 | 2660 |
]. |
1680 | 2661 |
] |
1401 | 2662 |
! ! |
2663 |
||
2664 |
!NoteBookView methodsFor:'obsolete'! |
|
2665 |
||
2279 | 2666 |
canvasFrameLevel |
2667 |
"ignorred |
|
2668 |
" |
|
2669 |
^ 0 |
|
2670 |
! |
|
2671 |
||
2672 |
canvasFrameLevel:anInteger |
|
2673 |
"ignorred |
|
2674 |
" |
|
2675 |
! |
|
2676 |
||
1401 | 2677 |
labels |
2678 |
"return the list of labels |
|
2679 |
" |
|
2680 |
^ self list |
|
2681 |
! |
|
2682 |
||
2683 |
labels:aListOfLabels |
|
2684 |
"set the list of labels |
|
2685 |
" |
|
2686 |
^ self list:aListOfLabels |
|
2687 |
! |
|
2688 |
||
2689 |
labelsHolder |
|
2690 |
"get the model, which keeps the list of Tabs or Labels |
|
2691 |
" |
|
2692 |
^ self listHolder |
|
2693 |
! |
|
2694 |
||
2695 |
labelsHolder:aValueHolder |
|
2696 |
"set the model, which keeps the list of Tabs or Labels |
|
2697 |
" |
|
2698 |
self listHolder:aValueHolder. |
|
2699 |
! ! |
|
2700 |
||
2701 |
!NoteBookView methodsFor:'private'! |
|
2702 |
||
3179 | 2703 |
indexOfTab:aTab |
2704 |
^ list indexOf:aTab |
|
2705 |
! |
|
2706 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2707 |
processAccessCharacter:aKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2708 |
"a character is pressed; check for tab identified y the character |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2709 |
select the tab and return true or if no tab detected return false |
1401 | 2710 |
" |
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2711 |
|j size char blck| |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2712 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2713 |
(aKey isCharacter and:[(size := list size) ~~ 0]) ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2714 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2715 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2716 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2717 |
size == selection ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2718 |
size == 1 ifTrue:[^ false]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2719 |
j := 1 |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2720 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2721 |
j := selection isNil ifTrue:[1] ifFalse:[selection + 1] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2722 |
]. |
1401 | 2723 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2724 |
char := aKey asLowercase. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2725 |
blck := [:i| ((list at:i) accessCharacter == char and:[self isSelectable:i]) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2726 |
self selection:i. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2727 |
^ true |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2728 |
] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2729 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2730 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2731 |
j to:size do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2732 |
1 to:(j-1) do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2733 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2734 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2735 |
! |
1401 | 2736 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2737 |
processShortcutKey:aKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2738 |
"if there is a short-key for that character, process it |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2739 |
and return true. Otherwise, return false. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2740 |
" |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2741 |
|j k size rawKey blck| |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2742 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2743 |
(size := list size) == 0 ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2744 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2745 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2746 |
rawKey := device keyboardMap keyAtValue:aKey ifAbsent:aKey. |
1401 | 2747 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2748 |
size == selection ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2749 |
size == 1 ifTrue:[^ false]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2750 |
j := 1 |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2751 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2752 |
j := selection isNil ifTrue:[1] ifFalse:[selection + 1] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2753 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2754 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2755 |
blck := [:i| k := (list at:i) shortcutKey. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2756 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2757 |
(k notNil and:[(self isSelectable:i) and:[(k == aKey or:[k == rawKey])]]) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2758 |
self selection:i. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2759 |
^ true |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2760 |
] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2761 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2762 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2763 |
j to:size do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2764 |
1 to:(j-1) do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2765 |
^ false |
3179 | 2766 |
! |
2767 |
||
2768 |
tabContainingPointX:x y:y |
|
2769 |
^ list detect:[:aTab| aTab containsPointX:x y:y ] ifNone:nil. |
|
1401 | 2770 |
! ! |
2771 |
||
2686 | 2772 |
!NoteBookView methodsFor:'private-buttons'! |
2773 |
||
2774 |
buttonLayoutUpdate |
|
2896 | 2775 |
|tabLayout bW h y w x e| |
2686 | 2776 |
|
2777 |
self hasScrollButtons ifFalse:[^ self]. |
|
2778 |
||
2779 |
(numberOfLines isNil or:[list size == 0]) ifTrue:[ |
|
2780 |
self transformation:nil. |
|
2706 | 2781 |
self hideButton:buttonPrev. |
2782 |
self hideButton:buttonNext. |
|
2686 | 2783 |
^ self |
2784 |
]. |
|
2896 | 2785 |
tabLayout := list first unselectedLayout. |
2691 | 2786 |
bW := self buttonWidth. |
2787 |
||
2788 |
self isHorizontal ifTrue:[ |
|
2896 | 2789 |
y := tabLayout top. |
2790 |
h := tabLayout height. |
|
2691 | 2791 |
e := bW @ h. |
2792 |
buttonPrev origin:(self tabLeftMargin)@y extent:e. |
|
2793 |
buttonNext origin:(self width - self tabRightMargin - bW) @ y extent:e. |
|
2794 |
] ifFalse:[ |
|
2896 | 2795 |
x := tabLayout left. |
2796 |
w := tabLayout width. |
|
2691 | 2797 |
e := w @ bW. |
2798 |
buttonPrev origin:x@(self tabLeftMargin) extent:e. |
|
2799 |
buttonNext origin:x@(self height - self tabRightMargin - bW) extent:e. |
|
2686 | 2800 |
]. |
2801 |
! |
|
2802 |
||
2803 |
buttonWidth |
|
2804 |
"returns the button extent x or y dependent on the layout |
|
2805 |
" |
|
2806 |
^ 16 |
|
2807 |
! |
|
2808 |
||
2706 | 2809 |
hideButton:aButton |
2810 |
aButton controller buttonRelease:#select x:0 y:0. |
|
2811 |
aButton unmap. |
|
2812 |
! |
|
2813 |
||
2686 | 2814 |
makeVisible:aTab |
2815 |
"setup transformation to make the selection visible; |
|
2816 |
returns true if the transformation has changed otherwise false. |
|
2817 |
" |
|
2691 | 2818 |
|layoutLast isHorizontal max maxAllowed oldTrans newTrans leftMargin rightMargin| |
2819 |
||
2820 |
(numberOfLines notNil and:[self hasScrollButtons]) ifFalse:[ |
|
2821 |
^ false |
|
2822 |
]. |
|
2686 | 2823 |
|
2687 | 2824 |
aTab isNil ifTrue:[ |
2825 |
list size == 0 ifTrue:[ |
|
2706 | 2826 |
self hideButton:buttonPrev. |
2827 |
self hideButton:buttonNext. |
|
2687 | 2828 |
self transformation:nil. |
2829 |
]. |
|
2830 |
^ false. |
|
2831 |
]. |
|
2686 | 2832 |
oldTrans := self transformation. |
2833 |
isHorizontal := self isHorizontal. |
|
2896 | 2834 |
layoutLast := list last unselectedLayout. |
2691 | 2835 |
leftMargin := self tabLeftMargin. |
2836 |
rightMargin := self tabRightMargin. |
|
2686 | 2837 |
|
2838 |
isHorizontal ifTrue:[ |
|
2691 | 2839 |
max := layoutLast right. |
2840 |
maxAllowed := self width - rightMargin. |
|
2686 | 2841 |
|
2842 |
max > maxAllowed ifTrue:[ |
|
2843 |
self makeVisibleHorizontal:aTab. |
|
2844 |
] ifFalse:[ |
|
2845 |
self transformation:nil. |
|
2846 |
]. |
|
2847 |
] ifFalse:[ |
|
2691 | 2848 |
max := layoutLast bottom. |
2849 |
maxAllowed := self height - rightMargin. |
|
2686 | 2850 |
|
2851 |
max > maxAllowed ifTrue:[ |
|
2852 |
self makeVisibleVertical:aTab. |
|
2853 |
] ifFalse:[ |
|
2854 |
self transformation:nil. |
|
2855 |
]. |
|
2856 |
]. |
|
2857 |
newTrans := self transformation. |
|
2858 |
||
2859 |
newTrans isNil ifTrue:[ |
|
2706 | 2860 |
self hideButton:buttonPrev. |
2686 | 2861 |
] ifFalse:[ |
2862 |
buttonPrev map. |
|
2863 |
||
2864 |
max := isHorizontal ifTrue:[newTrans applyToX:max] |
|
2865 |
ifFalse:[newTrans applyToY:max]. |
|
2866 |
]. |
|
2867 |
||
2868 |
max > maxAllowed ifTrue:[ |
|
2869 |
buttonNext map |
|
2870 |
] ifFalse:[ |
|
2706 | 2871 |
self hideButton:buttonNext. |
2686 | 2872 |
]. |
2873 |
^ oldTrans ~~ newTrans |
|
2874 |
! |
|
2875 |
||
2876 |
makeVisibleHorizontal:aTab |
|
2877 |
"setup transformation to make the horizontal selection visible |
|
2878 |
" |
|
2691 | 2879 |
|trans bounds xL xR xI minLeft maxRight| |
2880 |
||
2881 |
trans := self transformation. |
|
2882 |
bounds := self computeLayoutForTab:aTab. |
|
2883 |
xL := bounds left. |
|
2884 |
xI := self buttonWidth. |
|
2686 | 2885 |
|
2886 |
trans notNil ifTrue:[ xL := trans applyToX:xL ]. |
|
2887 |
||
2691 | 2888 |
minLeft := self tabLeftMargin. |
2889 |
||
2890 |
xL < (xI + minLeft) ifTrue:[ |
|
2686 | 2891 |
list first == aTab ifTrue:[ |
2892 |
trans := nil. |
|
2893 |
] ifFalse:[ |
|
2691 | 2894 |
trans := WindowingTransformation scale:nil translation:(((xI + minLeft) - bounds left) @ 0). |
2686 | 2895 |
]. |
2896 |
self transformation:trans. |
|
2897 |
^ self |
|
2898 |
]. |
|
2691 | 2899 |
xR := xL + bounds width. |
2900 |
maxRight := self width - self tabRightMargin. |
|
2901 |
||
2902 |
xR > (maxRight - xI) ifTrue:[ |
|
2686 | 2903 |
list last == aTab ifTrue:[ |
2904 |
xI := 0. |
|
2905 |
]. |
|
2691 | 2906 |
trans := WindowingTransformation scale:nil translation:((maxRight - xI - bounds right) @ 0). |
2686 | 2907 |
self transformation:trans. |
2908 |
]. |
|
2909 |
! |
|
2910 |
||
2911 |
makeVisibleVertical:aTab |
|
2912 |
"setup transformation to make the vertical selection visible |
|
2913 |
" |
|
2691 | 2914 |
|trans bounds xL xR xI minTop maxBot| |
2686 | 2915 |
|
2916 |
trans := self transformation. |
|
2917 |
bounds := self computeLayoutForTab:aTab. |
|
2918 |
xL := bounds top. |
|
2919 |
xI := self buttonWidth. |
|
2920 |
||
2921 |
trans notNil ifTrue:[ xL := trans applyToY:xL ]. |
|
2691 | 2922 |
minTop := self tabLeftMargin. |
2923 |
||
2924 |
xL < (xI + minTop) ifTrue:[ |
|
2686 | 2925 |
list first == aTab ifTrue:[ |
2926 |
trans := nil |
|
2927 |
] ifFalse:[ |
|
2691 | 2928 |
trans := WindowingTransformation scale:nil translation:(0@((minTop + xI) - bounds top)). |
2686 | 2929 |
]. |
2930 |
self transformation:trans. |
|
2931 |
^ self |
|
2932 |
]. |
|
2933 |
xR := xL + bounds height. |
|
2691 | 2934 |
maxBot := self height - self tabRightMargin. |
2935 |
||
2936 |
xR > (maxBot - xI) ifTrue:[ |
|
2686 | 2937 |
list last == aTab ifTrue:[ |
2938 |
xI := 0. |
|
2939 |
]. |
|
2691 | 2940 |
trans := WindowingTransformation scale:nil translation:(0@ (maxBot - xI - bounds bottom)). |
2686 | 2941 |
self transformation:trans. |
2942 |
]. |
|
2698 | 2943 |
! |
2944 |
||
2945 |
scrollButtonPressed:whichButton |
|
2896 | 2946 |
|trans idx isNext nIdx pIdx firstTabsLayout| |
2706 | 2947 |
|
2948 |
list isEmptyOrNil ifTrue:[^ self]. |
|
2698 | 2949 |
|
2950 |
whichButton == #scrollRight ifTrue:[ |
|
2951 |
isNext := true |
|
2952 |
] ifFalse:[ |
|
2953 |
whichButton == #scrollLeft ifFalse:[^ self]. |
|
2954 |
isNext := false. |
|
2955 |
]. |
|
2706 | 2956 |
trans := self transformation. |
2957 |
||
2896 | 2958 |
firstTabsLayout := list first unselectedLayout. |
2959 |
||
2960 |
self isHorizontal ifTrue:[ |
|
2961 |
|y xN xP| |
|
2962 |
y := firstTabsLayout top. |
|
2706 | 2963 |
xN := buttonNext origin x + 2. |
2964 |
xP := buttonPrev corner x - 2. |
|
2965 |
||
2966 |
trans notNil ifTrue:[ |
|
2967 |
xN := trans applyInverseToX:xN. |
|
2968 |
xP := trans applyInverseToX:xP. |
|
2698 | 2969 |
]. |
2706 | 2970 |
nIdx := list findFirst:[:aTab| aTab containsPointX:xN y:y ]. |
2971 |
pIdx := list findFirst:[:aTab| aTab containsPointX:xP y:y ]. |
|
2896 | 2972 |
] ifFalse:[ |
2973 |
|x yN yP| |
|
2974 |
x := firstTabsLayout left. |
|
2706 | 2975 |
yN := buttonNext origin y + 2. |
2976 |
yP := buttonPrev corner y - 2. |
|
2977 |
||
2978 |
trans notNil ifTrue:[ |
|
2979 |
yN := trans applyInverseToY:yN. |
|
2980 |
yP := trans applyInverseToY:yP. |
|
2698 | 2981 |
]. |
2706 | 2982 |
nIdx := list findFirst:[:aTab| aTab containsPointX:x y:yN ]. |
2983 |
pIdx := list findFirst:[:aTab| aTab containsPointX:x y:yP ]. |
|
2698 | 2984 |
]. |
2706 | 2985 |
idx := isNext ifTrue:[nIdx] ifFalse:[pIdx]. |
2986 |
||
2698 | 2987 |
idx == 0 ifTrue:[ |
2988 |
idx := isNext ifTrue:[list size] ifFalse:[1]. |
|
2706 | 2989 |
] ifFalse:[ |revIdx| |
2990 |
revIdx := isNext ifTrue:[pIdx] ifFalse:[nIdx]. |
|
2991 |
||
2992 |
revIdx == idx ifTrue:[ |
|
2993 |
isNext ifTrue:[ |
|
2994 |
idx := revIdx + 1 min:(list size). |
|
2995 |
] ifFalse:[ |
|
2996 |
idx := revIdx - 1 max:1. |
|
2997 |
] |
|
2998 |
]. |
|
2698 | 2999 |
]. |
3000 |
||
3001 |
(self makeVisible:(list at:idx ifAbsent:nil)) ifTrue:[ |
|
3002 |
self invalidate. |
|
3003 |
]. |
|
2686 | 3004 |
! ! |
3005 |
||
1401 | 3006 |
!NoteBookView methodsFor:'queries'! |
3007 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3008 |
hasTabSelected:aTab |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3009 |
^ aTab == self selectedTab |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3010 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3011 |
|
3208 | 3012 |
isDestroyTabButtonShownFor:aTab |
3013 |
"returns true if the destraoyButton for a tab is shown |
|
3014 |
" |
|
3015 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifFalse:[ |
|
3016 |
^ false |
|
3017 |
]. |
|
3018 |
self showDestroyButtonOfInactiveTabs ifTrue:[^ true]. |
|
3019 |
^ (self selectedTab == aTab) |
|
3020 |
! |
|
3021 |
||
1401 | 3022 |
isFirstTabInLine:aTab |
2279 | 3023 |
"returns true if the tab is the first tab in the line |
3024 |
used by drawing |
|
3025 |
" |
|
3026 |
|idx prevTab| |
|
1401 | 3027 |
|
3028 |
idx := list identityIndexOf:aTab. |
|
2279 | 3029 |
prevTab := list at:(idx - 1) ifAbsent:nil. |
3030 |
||
3031 |
^ prevTab isNil or:[prevTab lineNr ~~ aTab lineNr] |
|
1401 | 3032 |
! |
3033 |
||
3034 |
isLastTabInLine:aTab |
|
2279 | 3035 |
"returns true if the tab is the last tab in the line |
3036 |
used by drawing |
|
3037 |
" |
|
3038 |
|index nextTab| |
|
1401 | 3039 |
|
2279 | 3040 |
index := list identityIndexOf:aTab. |
3041 |
nextTab := list at:(index + 1) ifAbsent:nil. |
|
3042 |
||
3043 |
^ nextTab isNil or:[nextTab lineNr ~~ aTab lineNr] |
|
1401 | 3044 |
! ! |
3045 |
||
3046 |
!NoteBookView methodsFor:'selection'! |
|
375 | 3047 |
|
1401 | 3048 |
isSelectable:anIndex |
3049 |
"returns true if tab at an index is selectable |
|
3050 |
" |
|
3051 |
(anIndex notNil and:[anIndex between:1 and:list size]) ifTrue:[ |
|
3052 |
(list at:anIndex) isEnabled ifTrue:[ |
|
3053 |
^ selectConditionBlock isNil ifTrue:[true] |
|
3054 |
ifFalse:[selectConditionBlock value:anIndex] |
|
3055 |
] |
|
3056 |
]. |
|
3057 |
^ false |
|
3058 |
! |
|
3059 |
||
2396
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3060 |
nextSelectableAfter:anIndex wrapAtEnd:wrapAtEnd |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3061 |
"return the index of the next selectable entry after the index; |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3062 |
wrap at end if the wrapAtEnd flag is set to true. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3063 |
" |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3064 |
|size idx| |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3065 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3066 |
size := list size. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3067 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3068 |
size > 1 ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3069 |
idx := anIndex + 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3070 |
idx to:size do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3071 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3072 |
wrapAtEnd ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3073 |
idx := anIndex - 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3074 |
1 to:idx do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3075 |
] |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3076 |
]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3077 |
^ 0 |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3078 |
! |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3079 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3080 |
previousSelectableBefore:anIndex wrapAtBegin:wrapAtBegin |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3081 |
"return the index of the previous selectable entry before the index; |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3082 |
wrap at begin if the wrapAtBegin flag is set to true. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3083 |
" |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3084 |
|size idx| |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3085 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3086 |
size := list size. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3087 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3088 |
size > 1 ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3089 |
idx := anIndex - 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3090 |
idx to:1 by:-1 do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3091 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3092 |
wrapAtBegin ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3093 |
idx := anIndex + 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3094 |
size to:idx by:-1 do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3095 |
] |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3096 |
]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3097 |
^ 0 |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3098 |
! |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
3099 |
|
3179 | 3100 |
selectTab:aTab |
3101 |
|idx| |
|
3102 |
||
3103 |
idx := list indexOf:aTab. |
|
3104 |
self selection:(idx == 0 ifTrue:nil ifFalse:idx) |
|
3105 |
! |
|
3106 |
||
1401 | 3107 |
selectedTab |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3108 |
"returns the selected tab or nil" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3109 |
|
2279 | 3110 |
(selection notNil and:[selection ~~ 0]) ifTrue:[ |
3111 |
^ list at:selection ifAbsent:nil |
|
3112 |
]. |
|
3113 |
^ nil |
|
1401 | 3114 |
! |
3115 |
||
3116 |
selection |
|
2740 | 3117 |
"return the selection or nil/o; caring for the useIndex setting. |
1401 | 3118 |
" |
3119 |
selection isNil ifTrue:[ |
|
3120 |
^ useIndex ifTrue:[0] ifFalse:[nil] |
|
3121 |
]. |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3122 |
^ useIndex ifTrue:[selection] ifFalse:[self selectedTab labelOrTabItem] |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3123 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3124 |
"Modified: / 06-09-2006 / 17:04:42 / cg" |
1401 | 3125 |
! |
3126 |
||
3127 |
selection:anIndexOrNil |
|
3128 |
"change the selection to index or nil. The model and/or actionBlock is notified |
|
3129 |
" |
|
3130 |
|oldSel| |
|
3131 |
||
1407 | 3132 |
anIndexOrNil ~~ selection ifTrue:[ |
3133 |
oldSel := selection. |
|
3134 |
self setSelection:anIndexOrNil. |
|
3135 |
oldSel ~~ selection ifTrue:[self selectionChanged] |
|
3136 |
] |
|
1401 | 3137 |
! |
3138 |
||
3139 |
selectionChanged |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3140 |
"selection has changed; update the model and evaluate change action" |
2532 | 3141 |
|
1401 | 3142 |
|sel| |
3143 |
||
3144 |
sel := self selection. |
|
3145 |
||
3146 |
model notNil ifTrue:[model value:sel]. |
|
3147 |
action notNil ifTrue:[action value:sel] |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3148 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3149 |
"Modified: / 06-09-2006 / 11:36:34 / cg" |
1401 | 3150 |
! |
3151 |
||
3152 |
setSelection:anIndexOrNil |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3153 |
"change the selection to anIndexOrNil. No notifications are raised" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3154 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3155 |
|newSelIndex newSelTab oldSelTab oldBounds newBounds| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3156 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3157 |
newSelIndex := self listIndexOf:anIndexOrNil. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3158 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3159 |
(newSelIndex notNil and:[(self isSelectable:newSelIndex) not]) ifTrue:[ |
2918
1acb9c8d8ac9
do not change the selection to nil, if new selection is not selectable.
Claus Gittinger <cg@exept.de>
parents:
2906
diff
changeset
|
3160 |
"/ newSelIndex := nil |
1acb9c8d8ac9
do not change the selection to nil, if new selection is not selectable.
Claus Gittinger <cg@exept.de>
parents:
2906
diff
changeset
|
3161 |
^ self "/ no change |
1401 | 3162 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3163 |
selection == newSelIndex ifTrue:[^ self]. |
1401 | 3164 |
|
2686 | 3165 |
numberOfLines isNil ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3166 |
selection := newSelIndex. |
2686 | 3167 |
^ self. |
3168 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3169 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3170 |
oldSelTab := self selectedTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3171 |
oldSelTab notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3172 |
oldBounds := (self computeLayoutForTab:oldSelTab) merge:oldSelTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3173 |
oldSelTab layout:(oldSelTab unselectedLayout). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3174 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3175 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3176 |
selection := newSelIndex. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3177 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3178 |
newSelTab := self selectedTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3179 |
newSelTab notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3180 |
newBounds := self computeLayoutForTab:newSelTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3181 |
newSelTab layout:newBounds. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3182 |
newBounds := newSelTab selectedLayout merge:newSelTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3183 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3184 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3185 |
(self makeVisible:newSelTab) ifTrue:[ |
2686 | 3186 |
self invalidate. |
3187 |
] ifFalse:[ |
|
3188 |
shown ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3189 |
oldBounds notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3190 |
self invalidate:oldBounds |
2215 | 3191 |
]. |
2686 | 3192 |
newBounds notNil ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3193 |
self invalidate:newBounds |
2686 | 3194 |
] |
2215 | 3195 |
]. |
1759 | 3196 |
]. |
2725 | 3197 |
self validateVisibleCanvas. |
3198 |
! |
|
3199 |
||
3336
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
3200 |
userSelection:anIndexOrNil |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
3201 |
"user changed the selection to index or nil. The model and/or actionBlock is notified" |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
3202 |
|
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
3203 |
lastUserSelection := anIndexOrNil. |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
3204 |
self selection:anIndexOrNil |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
3205 |
! |
5d007baac61b
remember the last EXPLICIT user selection
Claus Gittinger <cg@exept.de>
parents:
3297
diff
changeset
|
3206 |
|
2725 | 3207 |
validateVisibleCanvas |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3208 |
|tabItem newCanvas selectedTab| |
2725 | 3209 |
|
3210 |
selectedTab := self selectedTab. |
|
3211 |
||
3212 |
selectedTab notNil ifTrue:[ |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3213 |
tabItem := selectedTab tabItem. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3214 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3215 |
tabItem isNil ifTrue:[ |
2725 | 3216 |
^ self |
3217 |
]. |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3218 |
"/ tabItem minorKey notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3219 |
"/ tabItem majorKey isNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3220 |
"/ tabItem majorKey:(self application class). |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3221 |
"/ ]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3222 |
"/ ]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3223 |
newCanvas := tabItem canvasView. |
1759 | 3224 |
]. |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
3225 |
|
2725 | 3226 |
newCanvas == canvas ifTrue:[ |
1759 | 3227 |
^ self |
3228 |
]. |
|
3229 |
||
2725 | 3230 |
canvas notNil ifTrue:[ |
3231 |
(canvas objectAttributeAt:#isTabItem) == true ifFalse:[ |
|
3232 |
^ self. |
|
3233 |
] |
|
3234 |
]. |
|
3235 |
self canvas:newCanvas. |
|
3236 |
||
1759 | 3237 |
canvasHolder notNil ifTrue:[ |
2725 | 3238 |
canvasHolder value:newCanvas. |
1759 | 3239 |
]. |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3240 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3241 |
"Modified: / 06-09-2006 / 16:02:10 / cg" |
1401 | 3242 |
! ! |
3243 |
||
3244 |
!NoteBookView::Tab class methodsFor:'instance creation'! |
|
3245 |
||
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3246 |
label:aLabel on:aView |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3247 |
^ self basicNew label:aLabel on:aView |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3248 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3249 |
"Modified: / 06-09-2006 / 16:20:45 / cg" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3250 |
! |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3251 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3252 |
labelOrTabItem:aLabel on:aView |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3253 |
^ self basicNew labelOrTabItem:aLabel on:aView |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3254 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3255 |
"Created: / 06-09-2006 / 16:54:03 / cg" |
1401 | 3256 |
! ! |
3257 |
||
3258 |
!NoteBookView::Tab methodsFor:'accessing'! |
|
3259 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3260 |
accessCharacter |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3261 |
"returns the access character or nil" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3262 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3263 |
^ accessCharacter |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3264 |
! |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3265 |
|
2288 | 3266 |
foregroundColor |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3267 |
"returns the foregroundColor or nil" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3268 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3269 |
tabItem notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3270 |
^ tabItem foregroundColor |
2288 | 3271 |
]. |
3272 |
^ nil |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3273 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3274 |
"Modified: / 06-09-2006 / 16:00:27 / cg" |
2288 | 3275 |
! |
3276 |
||
1401 | 3277 |
label |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3278 |
"returns my original label" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3279 |
|
1401 | 3280 |
^ label |
3281 |
! |
|
3282 |
||
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3283 |
label:aLabelOrTabItem on:aView |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3284 |
"initialize attributes" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3285 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3286 |
label := aLabelOrTabItem. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3287 |
(aLabelOrTabItem isKindOf:TabItem) ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3288 |
tabItem := aLabelOrTabItem. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3289 |
printableLabel := tabItem rawLabel. |
1401 | 3290 |
] ifFalse:[ |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3291 |
tabItem := nil. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3292 |
printableLabel := aLabelOrTabItem. |
1401 | 3293 |
]. |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3294 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3295 |
self getPrintableLabelFor:aView. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3296 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3297 |
"Modified: / 06-09-2006 / 16:45:54 / cg" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3298 |
! |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3299 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3300 |
labelOrTabItem |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3301 |
"returns my original label" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3302 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3303 |
^ label |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3304 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3305 |
"Created: / 06-09-2006 / 16:42:16 / cg" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3306 |
! |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3307 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3308 |
labelOrTabItem:aLabelOrTabItem on:aView |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3309 |
"initialize attributes" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3310 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3311 |
label := aLabelOrTabItem. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3312 |
(aLabelOrTabItem isKindOf:TabItem) ifTrue:[ |
3297 | 3313 |
"/ CG: iff the only need for the view in a tabItem is to get the atributes, |
3314 |
"/ then we should do things here (see below). |
|
3315 |
"/ Q to ca: is this correct ??? |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3316 |
tabItem := aLabelOrTabItem. |
3517
28e67762acd0
Fix example in TabItem (view without application)
Stefan Vogel <sv@exept.de>
parents:
3515
diff
changeset
|
3317 |
aView application notNil ifTrue:[ |
28e67762acd0
Fix example in TabItem (view without application)
Stefan Vogel <sv@exept.de>
parents:
3515
diff
changeset
|
3318 |
tabItem setAttributesWithBuilder:aView application builder. |
28e67762acd0
Fix example in TabItem (view without application)
Stefan Vogel <sv@exept.de>
parents:
3515
diff
changeset
|
3319 |
]. |
3297 | 3320 |
"/ CG: this is the old code, which makes UBSxxx tab-app reuse impossible |
3321 |
"/ tabItem view:aView. |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3322 |
printableLabel := tabItem rawLabel. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3323 |
] ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3324 |
tabItem := nil. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3325 |
printableLabel := aLabelOrTabItem. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3326 |
]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3327 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3328 |
self getPrintableLabelFor:aView. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3329 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3330 |
"Created: / 06-09-2006 / 16:53:53 / cg" |
1401 | 3331 |
! |
3332 |
||
3207 | 3333 |
lastFocusViewId |
3334 |
"get the id of the view which had the last focus or nil" |
|
3335 |
||
3336 |
^ lastFocusViewId |
|
3337 |
! |
|
3338 |
||
3339 |
lastFocusViewId:anIdOrNil |
|
3340 |
"set the id of the view which has the last focus or nil" |
|
3341 |
||
3342 |
lastFocusViewId := anIdOrNil. |
|
3343 |
! |
|
3344 |
||
1401 | 3345 |
lineNr |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3346 |
"get the line number within the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3347 |
|
1401 | 3348 |
^ lineNr |
3349 |
! |
|
3350 |
||
3351 |
lineNr:aLineNr |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3352 |
"set the line number within the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3353 |
|
1401 | 3354 |
lineNr := aLineNr |
3355 |
! |
|
3356 |
||
1759 | 3357 |
model |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3358 |
"returns the model, a TabItem or nil" |
3507 | 3359 |
"/ self halt. |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3360 |
^ tabItem |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3361 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3362 |
"Modified: / 06-09-2006 / 16:01:36 / cg" |
1759 | 3363 |
! |
3364 |
||
1401 | 3365 |
printableLabel |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3366 |
"get my printable label" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3367 |
|
1401 | 3368 |
^ printableLabel |
3369 |
! |
|
3370 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3371 |
shortcutKey |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3372 |
"get the key to press to select the tab item from the keyboard" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3373 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3374 |
tabItem notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3375 |
^ tabItem shortcutKey |
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3376 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3377 |
^ nil |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3378 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3379 |
"Modified: / 06-09-2006 / 16:01:29 / cg" |
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3380 |
! |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
3381 |
|
1401 | 3382 |
string |
3383 |
"access the printable string used for steping through a list |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3384 |
searching for an entry starting with a character." |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3385 |
|
1401 | 3386 |
^ printableLabel perform:#string ifNotUnderstood:nil |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3387 |
! |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3388 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3389 |
tabItem |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3390 |
"returns the model, a TabItem or nil" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3391 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3392 |
^ tabItem |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3393 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3394 |
"Created: / 06-09-2006 / 16:01:05 / cg" |
1401 | 3395 |
! ! |
3396 |
||
1818 | 3397 |
!NoteBookView::Tab methodsFor:'accessing-dimensions'! |
1401 | 3398 |
|
3399 |
extent |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3400 |
"returns the extent of the label, the minimum size required by the tab" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3401 |
|
1401 | 3402 |
^ extent |
3403 |
! |
|
3404 |
||
3405 |
layout |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3406 |
"get the tab's current layout, set by the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3407 |
|
1401 | 3408 |
^ layout |
3409 |
! |
|
3410 |
||
3411 |
layout:aLayout |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3412 |
"set the tab's current layout" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3413 |
|
2896 | 3414 |
layout := aLayout. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3415 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3416 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3417 |
selectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3418 |
"get the tab's selectedLayout, set by the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3419 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3420 |
^ selectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3421 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3422 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3423 |
selectedLayout:aLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3424 |
"set the tab's selectedLayout" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3425 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3426 |
selectedLayout := aLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3427 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3428 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3429 |
unselectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3430 |
"get the tab's unselectedLayout, set by the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3431 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3432 |
^ unselectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3433 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3434 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3435 |
unselectedLayout:aLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3436 |
"set the tab's unselectedLayout" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3437 |
|
2896 | 3438 |
unselectedLayout := aLayout. |
1401 | 3439 |
! ! |
3440 |
||
1818 | 3441 |
!NoteBookView::Tab methodsFor:'accessing-mvc'! |
1401 | 3442 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3443 |
addDependent:aGC |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3444 |
"make the noteBook be a dependent of the tab model" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3445 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3446 |
tabItem notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3447 |
tabItem addDependent:aGC |
1759 | 3448 |
] |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3449 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3450 |
"Modified: / 06-09-2006 / 16:00:20 / cg" |
1401 | 3451 |
! |
3452 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3453 |
removeDependent:aGC |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3454 |
"make the noteBook be independent of the tab model" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3455 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3456 |
tabItem notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3457 |
tabItem destroyCanvas. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3458 |
tabItem removeDependent:aGC. |
1759 | 3459 |
] |
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3460 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3461 |
"Modified: / 06-09-2006 / 16:01:17 / cg" |
1401 | 3462 |
! ! |
3463 |
||
3464 |
!NoteBookView::Tab methodsFor:'drawing'! |
|
3465 |
||
3208 | 3466 |
displayOn:aGC inset:inset direction:aDirection textRightInset:aTextRightInset |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3467 |
"redraw this tab" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3468 |
|
3208 | 3469 |
|dispObj lft wdt top hgt x y| |
1401 | 3470 |
|
3471 |
"/ REDRAW LABEL |
|
3472 |
(aGC isEnabled and:[self isEnabled]) ifTrue:[ |
|
3473 |
dispObj := printableLabel. |
|
3474 |
] ifFalse:[ |
|
3475 |
(dispObj := disabledLabel) isNil ifTrue:[ |
|
3476 |
(dispObj := printableLabel) isImageOrForm ifTrue:[ |
|
3477 |
disabledLabel := printableLabel lightened onDevice:(aGC device) |
|
375 | 3478 |
] |
1401 | 3479 |
] |
3480 |
]. |
|
1442 | 3481 |
|
1401 | 3482 |
(aDirection == #top or:[aDirection == #bottom]) ifTrue:[ |
3208 | 3483 |
wdt := layout width - inset - inset - aTextRightInset. |
2288 | 3484 |
wdt > 4 ifFalse:[^ self]. |
3208 | 3485 |
lft := layout left + inset. |
2288 | 3486 |
|
3487 |
x := (wdt - extent x) // 2. |
|
3488 |
x < 0 ifTrue:[ |
|
3489 |
dispObj := '...'. |
|
3490 |
x := 0. |
|
3491 |
]. |
|
3492 |
x := x + lft. |
|
3208 | 3493 |
y := layout top + ((layout height - inset - extent y - 1) // 2). |
2288 | 3494 |
|
3495 |
aDirection == #top ifTrue:[ y := y + inset ]. |
|
1401 | 3496 |
|
2485
b3d92f4a5f7b
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2431
diff
changeset
|
3497 |
y := y + (dispObj ascentOn:aGC). |
2283 | 3498 |
dispObj displayOn:aGC x:x y:y. |
2485
b3d92f4a5f7b
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2431
diff
changeset
|
3499 |
^ self |
2283 | 3500 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3501 |
|
3208 | 3502 |
hgt := layout height - inset - inset - aTextRightInset. |
2288 | 3503 |
hgt > 4 ifFalse:[^ self]. |
3208 | 3504 |
top := layout top + inset. |
2288 | 3505 |
|
3506 |
y := (hgt - extent x) // 2. |
|
3507 |
y < 0 ifTrue:[ |
|
3508 |
dispObj := '...'. |
|
3509 |
y := 0. |
|
3510 |
]. |
|
3511 |
y := y + top. |
|
3208 | 3512 |
x := layout left + ((layout width - inset - extent y +2) // 2). |
2288 | 3513 |
|
3514 |
aDirection == #left ifTrue:[ x := x + inset ]. |
|
2283 | 3515 |
|
3516 |
dispObj isImageOrForm ifFalse:[ |
|
3517 |
dispObj isString ifTrue:[ |
|
3518 |
x := x + aGC font descent. |
|
1683 | 3519 |
]. |
2283 | 3520 |
"/ workaround for a bug in display-with-angle, |
3521 |
"/ iff displayed string is a labelAndIcon. |
|
3522 |
"/ (In this case, display is always opaque, and the current |
|
3523 |
"/ backgroundPaint color is used to fill the underlying rectangle) |
|
3524 |
"/ |
|
3525 |
aGC backgroundPaint:aGC backgroundColor. |
|
3526 |
aGC displayString:dispObj x:x y:y angle:90. |
|
3527 |
] ifTrue:[ |
|
3528 |
(dispObj rotated:90) displayOn:aGC x:x y:y. |
|
3529 |
]. |
|
375 | 3530 |
! ! |
3531 |
||
1677 | 3532 |
!NoteBookView::Tab methodsFor:'private'! |
3533 |
||
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3534 |
getPrintableLabelFor:aGC |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3535 |
printableLabel notNil ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3536 |
printableLabel isImageOrForm ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3537 |
printableLabel := printableLabel onDevice:(aGC device) |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3538 |
] ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3539 |
printableLabel isString ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3540 |
printableLabel := self resolveDisplayStringFor:printableLabel on:aGC. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3541 |
] ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3542 |
printableLabel class == LabelAndIcon ifTrue:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3543 |
printableLabel string:(self resolveDisplayStringFor:(printableLabel string) on:aGC) |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3544 |
] |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3545 |
]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3546 |
] |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3547 |
] ifFalse:[ |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3548 |
printableLabel := '' |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3549 |
]. |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3550 |
extent := (printableLabel widthOn:aGC) @ (printableLabel heightOn:aGC). |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3551 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3552 |
"Created: / 06-09-2006 / 16:45:31 / cg" |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3553 |
! |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3554 |
|
2629 | 3555 |
resolveDisplayStringFor:aString on:aNoteBook |
1677 | 3556 |
|string size rest pos idx| |
3557 |
||
2629 | 3558 |
accessCharacter := nil. |
3559 |
string := aNoteBook translateToDisplayLabel:aString. |
|
3560 |
size := string size. |
|
1677 | 3561 |
pos := 0. |
3562 |
||
2629 | 3563 |
size == 0 ifTrue:[ ^ string ]. |
3564 |
||
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3565 |
(tabItem notNil and:[(pos := tabItem accessCharacterPosition) ~~ 0]) ifTrue:[ |
2629 | 3566 |
pos > size ifTrue:[pos := 0] |
3567 |
] ifFalse:[ |
|
3568 |
idx := 1. |
|
3569 |
||
3570 |
[((idx := string indexOf:$& startingAt:idx) ~~ 0 and:[idx < size])] whileTrue:[ |
|
3571 |
rest := string copyFrom:(idx+1). |
|
3572 |
||
3573 |
idx == 1 ifTrue:[string := rest] |
|
3574 |
ifFalse:[string := (string copyFrom:1 to:(idx-1)), rest]. |
|
3575 |
||
3576 |
(string at:idx) == $& ifTrue:[idx := idx + 1] |
|
3577 |
ifFalse:[pos := idx]. |
|
3578 |
size := size - 1. |
|
1677 | 3579 |
] |
3580 |
]. |
|
2629 | 3581 |
|
1677 | 3582 |
size ~~ 0 ifTrue:[ |
3583 |
pos == 0 ifTrue:[ |
|
3584 |
pos := 1 |
|
3585 |
] ifFalse:[ |
|
3586 |
string isText ifFalse:[ |
|
3587 |
string := Text string:string |
|
3588 |
]. |
|
3589 |
string emphasisAt:pos add:#underline |
|
3590 |
]. |
|
3591 |
accessCharacter := (string at:pos) asLowercase |
|
3592 |
]. |
|
3593 |
^ string |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3594 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3595 |
"Modified: / 06-09-2006 / 16:01:25 / cg" |
1677 | 3596 |
! ! |
3597 |
||
1401 | 3598 |
!NoteBookView::Tab methodsFor:'testing'! |
375 | 3599 |
|
1401 | 3600 |
containsPointX:x y:y |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3601 |
"return true, if the point defined by x@y is contained in the tab." |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3602 |
|
2279 | 3603 |
layout isNil ifTrue:[^ false]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3604 |
^ layout containsPointX:x y:y |
375 | 3605 |
! |
3606 |
||
1401 | 3607 |
intersects:aRectangle |
3608 |
"return true, if the intersection between the argument, aRectangle |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3609 |
and the tab is not empty" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3610 |
|
2279 | 3611 |
layout isNil ifTrue:[^ false]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3612 |
^ layout intersects:aRectangle |
1401 | 3613 |
! |
432 | 3614 |
|
1401 | 3615 |
isEnabled |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3616 |
"returne true if no model exists or the model is enabled" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3617 |
|
3069
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3618 |
^ (tabItem isNil or:[ tabItem isEnabled ]) |
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3619 |
|
04afcd5b61cb
that code sucked - it still does, but less so.
Claus Gittinger <cg@exept.de>
parents:
2953
diff
changeset
|
3620 |
"Modified: / 06-09-2006 / 16:00:35 / cg" |
386 | 3621 |
! ! |
3622 |
||
355 | 3623 |
!NoteBookView class methodsFor:'documentation'! |
3624 |
||
3625 |
version |
|
3517
28e67762acd0
Fix example in TabItem (view without application)
Stefan Vogel <sv@exept.de>
parents:
3515
diff
changeset
|
3626 |
^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.148 2008-08-01 16:33:52 stefan Exp $' |
355 | 3627 |
! ! |