167 savClip := clipRect. |
167 savClip := clipRect. |
168 |
168 |
169 self clippingRectangle:(Rectangle left:x top:y width:w height:h). |
169 self clippingRectangle:(Rectangle left:x top:y width:w height:h). |
170 |
170 |
171 items do:[:anItem| |
171 items do:[:anItem| |
172 anItem isDrawable ifTrue:[ |
172 layout := anItem layout. |
173 layout := anItem layout. |
173 left := layout left. |
174 left := layout left. |
174 width := layout width. |
175 width := layout width. |
175 |
176 |
176 (left < maxX and:[layout right > x]) ifTrue:[ |
177 (left < maxX and:[layout right > x]) ifTrue:[ |
177 (bg := anItem backgroundColor) notNil ifTrue:[ |
178 (bg := anItem backgroundColor) notNil ifTrue:[ |
178 bg ~= bgColor ifTrue:[ |
179 bg ~= bgColor ifTrue:[ |
179 self paint:bg. |
180 self paint:bg. |
180 self fillRectangleX:left y:y width:width height:h. |
181 self fillRectangleX:left y:y width:width height:h. |
181 ] |
182 ] |
182 ] ifFalse:[ |
183 ] ifFalse:[ |
183 bg := bgColor |
184 bg := bgColor |
184 ]. |
185 ]. |
185 |
186 |
186 fg := (anItem foregroundColor) ? fgColor. |
187 fg := (anItem foregroundColor) ? fgColor. |
187 lv := selection == anItem ifTrue:[actLvl] ifFalse:[pasLvl]. |
188 lv := selection == anItem ifTrue:[actLvl] ifFalse:[pasLvl]. |
188 self paint:fg on:bg. |
189 self paint:fg on:bg. |
189 anItem redrawLabelOn:self hInset:inset + (lv abs). |
190 anItem redrawLabelOn:self hInset:inset + (lv abs). |
190 columnView drawEdgesAtX:left y:0 width:width height:height level:lv on:self |
191 columnView drawEdgesAtX:left y:0 width:width height:height level:lv on:self |
|
192 ] |
|
193 ] |
191 ] |
194 ]. |
192 ]. |
195 self clippingRectangle:savClip. |
193 self clippingRectangle:savClip. |
196 |
194 |
197 |
195 |
308 ! |
306 ! |
309 |
307 |
310 columnsSizeChanged |
308 columnsSizeChanged |
311 "the list of columns changed; recreate all items |
309 "the list of columns changed; recreate all items |
312 " |
310 " |
313 |height font lastCol prevCol| |
311 |height font| |
314 |
312 |
315 items := OrderedCollection new. |
313 items := OrderedCollection new. |
316 font := columnView font. |
314 |
317 height := 0. |
315 columnView numberOfColumns ~~ 0 ifTrue:[ |
318 |
316 font := columnView font. |
319 columnView numberOfColumns == 0 ifTrue:[ |
317 height := 0. |
320 ^ self redraw |
318 |
321 ]. |
319 columnView columnsDo:[:aColumn||item| |
322 lastCol := columnView lastColumn. |
320 items add:(item := Item column:aColumn font:font on:self). |
323 prevCol := nil. |
321 height := (item preferredExtent y) max:height. |
324 |
322 ]. |
325 columnView columnsDo:[:aColumn||item| |
323 height := height + self class verticalInset. |
326 items add:(item := Item column:aColumn font:font on:self). |
324 self updateLayoutsHeight:height. |
327 |
325 self bottomInset:height negated. |
328 item isDrawable ifTrue:[ |
326 ]. |
329 height := (item preferredExtent y) max:height. |
|
330 prevCol := aColumn showColSeparator ifTrue:[nil] ifFalse:[aColumn]. |
|
331 ] ifFalse:[ |
|
332 prevCol isNil ifTrue:[ |
|
333 (aColumn == lastCol or:[aColumn showColSeparator]) ifTrue:[ |
|
334 prevCol := nil. |
|
335 item makeDrawable. |
|
336 ] |
|
337 ] |
|
338 ] |
|
339 ]. |
|
340 height := height + self class verticalInset. |
|
341 |
|
342 self updateLayoutsHeight:height. |
|
343 self bottomInset:height negated. |
|
344 self redraw. |
327 self redraw. |
345 |
328 |
346 ! ! |
329 ! ! |
347 |
330 |
348 !DSVLabelView methodsFor:'private'! |
331 !DSVLabelView methodsFor:'private'! |
358 ! |
341 ! |
359 |
342 |
360 updateLayoutsHeight:h |
343 updateLayoutsHeight:h |
361 "update the rectangle layout for each item based on a height |
344 "update the rectangle layout for each item based on a height |
362 " |
345 " |
363 |idx x0 x1 x col| |
346 |i x w| |
364 |
347 |
365 idx := 1. |
348 i := 1. |
366 x1 := 0. |
349 x := columnView margin - columnView xOriginOfContents. |
367 x1 := columnView has3Dseparators ifTrue:[0] ifFalse:[1]. |
350 columnView has3Dseparators ifFalse:[ x := x + 1]. |
368 x0 := columnView margin - columnView xOriginOfContents. |
351 |
369 col := nil. |
352 columnView columnsDo:[:aCol| |
370 |
353 w := aCol width. |
371 columnView columnsDo:[:aCol||itm w| |
354 (items at:i) layout:(Rectangle origin:(x @ 0) extent:(w @ h)). |
372 w := aCol width. |
355 i := i + 1. |
373 x1 := x1 + w. |
356 x := x + w. |
374 itm := items at:idx. |
357 ]. |
375 idx := idx + 1. |
|
376 |
|
377 (itm isDrawable or:[aCol showColSeparator]) ifTrue:[ |
|
378 col notNil ifTrue:[ |
|
379 itm isDrawable ifTrue:[ |
|
380 x := x1 - w. |
|
381 x1 := w. |
|
382 ] ifFalse:[ |
|
383 x := x1. |
|
384 x1 := 0 |
|
385 ]. |
|
386 col layout:(Rectangle origin:(x0 @ 0) extent:(x @ h)). |
|
387 x0 := x0 + x. |
|
388 col := nil. |
|
389 ]. |
|
390 |
|
391 itm isDrawable ifTrue:[ |
|
392 col := itm. |
|
393 ] |
|
394 ] |
|
395 ]. |
|
396 |
|
397 col notNil ifTrue:[ |
|
398 col layout:(Rectangle origin:(x0 @ 0) extent:(x1 @ h)). |
|
399 ]. |
|
400 |
|
401 |
|
402 |
|
403 ! ! |
358 ! ! |
404 |
359 |
405 !DSVLabelView::Item class methodsFor:'constants'! |
360 !DSVLabelView::Item class methodsFor:'constants'! |
406 |
361 |
407 defaultLayout |
362 defaultLayout |
428 selector <Symbol> a selector, which is evaluated with the argument |
383 selector <Symbol> a selector, which is evaluated with the argument |
429 if the item is selected and the button is released. |
384 if the item is selected and the button is released. |
430 |
385 |
431 argument <Object> user defined argument for the selector. |
386 argument <Object> user defined argument for the selector. |
432 |
387 |
433 isDrawable <Boolean> computed: is the label drawable |
|
434 |
|
435 adjust <Symbol> align label left, right or center; default is center |
388 adjust <Symbol> align label left, right or center; default is center |
436 |
389 |
437 font <Font> font used to dispaly the label; if the font is |
390 font <Font> font used to dispaly the label; if the font is |
438 undefined, the default font is used. |
391 undefined, the default font is used. |
439 |
392 |
579 |
524 |
580 label := aColumn label. |
525 label := aColumn label. |
581 selector := aColumn description labelActionSelector. |
526 selector := aColumn description labelActionSelector. |
582 argument := (aColumn description labelActionArgument) ? label. |
527 argument := (aColumn description labelActionArgument) ? label. |
583 |
528 |
584 preferredExtent := 0 @ 0. |
|
585 adjust := aColumn labelAlignment. |
529 adjust := aColumn labelAlignment. |
586 layout := self class defaultLayout. |
530 layout := self class defaultLayout. |
587 |
531 |
588 (fgColor := aColumn labelForegroundColor) notNil ifTrue:[ |
532 (fgColor := aColumn labelForegroundColor) notNil ifTrue:[ |
589 fgColor := fgColor on:(aGC device) |
533 fgColor := fgColor on:(aGC device) |