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