1397 ! |
1401 ! |
1398 |
1402 |
1399 label:aLabel on:aGC |
1403 label:aLabel on:aGC |
1400 "initialize attributes |
1404 "initialize attributes |
1401 " |
1405 " |
1402 |i string size rest ipos| |
1406 label := aLabel. |
1403 |
1407 model := (aLabel isKindOf:TabItem) ifTrue:[aLabel] ifFalse:[nil]. |
1404 label := aLabel. |
|
1405 model := (aLabel isKindOf:TabItem) ifTrue:[aLabel] ifFalse:[nil]. |
|
1406 accessCharacter := nil. |
1408 accessCharacter := nil. |
1407 |
1409 printableLabel := model notNil ifTrue:[model rawLabel] ifFalse:[aLabel]. |
1408 printableLabel := model notNil ifTrue:[model rawLabel] |
|
1409 ifFalse:[aLabel]. |
|
1410 |
1410 |
1411 printableLabel notNil ifTrue:[ |
1411 printableLabel notNil ifTrue:[ |
1412 printableLabel isImageOrForm ifTrue:[ |
1412 printableLabel isImageOrForm ifTrue:[ |
1413 printableLabel := printableLabel onDevice:(aGC device) |
1413 printableLabel := printableLabel onDevice:(aGC device) |
1414 ] ifFalse:[ |
1414 ] ifFalse:[ |
1415 printableLabel isString ifTrue:[ |
1415 printableLabel isString ifTrue:[ |
1416 ipos := 0. |
1416 printableLabel := self resolveDisplayStringFor:printableLabel |
1417 size := printableLabel size. |
1417 ] ifFalse:[ |
1418 |
1418 printableLabel class == LabelAndIcon ifTrue:[ |
1419 size > 1 ifTrue:[ |
1419 printableLabel string:(self resolveDisplayStringFor:(printableLabel string)) |
1420 model notNil ifTrue:[ |
1420 ] |
1421 ipos := model accessCharacterPosition. |
|
1422 ipos > size ifTrue:[ipos := 0]. |
|
1423 ]. |
|
1424 i := 1. |
|
1425 |
|
1426 [((i := printableLabel indexOf:$& startingAt:i) ~~ 0 |
|
1427 and:[i < size])] whileTrue:[ |
|
1428 rest := printableLabel copyFrom:(i+1). |
|
1429 |
|
1430 i == 1 ifTrue:[printableLabel := rest] |
|
1431 ifFalse:[printableLabel := (printableLabel copyFrom:1 to:(i-1)), rest]. |
|
1432 |
|
1433 (printableLabel at:i) == $& ifTrue:[i := i + 1] |
|
1434 ifFalse:[ipos := i]. |
|
1435 size := size - 1. |
|
1436 ]. |
|
1437 ipos ~~ 0 ifTrue:[ |
|
1438 printableLabel isText ifFalse:[ |
|
1439 printableLabel := Text string:printableLabel |
|
1440 ]. |
|
1441 printableLabel emphasisAt:ipos add:#underline. |
|
1442 ] |
|
1443 ]. |
|
1444 accessCharacter := printableLabel at:(ipos max:1) ifAbsent:nil. |
|
1445 accessCharacter := accessCharacter asLowercase. |
|
1446 ]. |
1421 ]. |
1447 ] |
1422 ] |
1448 ] ifFalse:[ |
1423 ] ifFalse:[ |
1449 printableLabel := '' |
1424 printableLabel := '' |
1450 ]. |
1425 ]. |
1799 "" |
1774 "" |
1800 |
1775 |
1801 |
1776 |
1802 ! ! |
1777 ! ! |
1803 |
1778 |
|
1779 !NoteBookView::Tab methodsFor:'private'! |
|
1780 |
|
1781 resolveDisplayStringFor:aString |
|
1782 |string size rest pos idx| |
|
1783 |
|
1784 size := aString size. |
|
1785 string := aString. |
|
1786 pos := 0. |
|
1787 |
|
1788 size > 1 ifTrue:[ |
|
1789 (model notNil and:[(pos := model accessCharacterPosition) ~~ 0]) ifTrue:[ |
|
1790 pos > size ifTrue:[pos := 0] |
|
1791 ] ifFalse:[ |
|
1792 idx := 1. |
|
1793 |
|
1794 [((idx := string indexOf:$& startingAt:idx) ~~ 0 and:[idx < size])] whileTrue:[ |
|
1795 rest := string copyFrom:(idx+1). |
|
1796 |
|
1797 idx == 1 ifTrue:[string := rest] |
|
1798 ifFalse:[string := (string copyFrom:1 to:(idx-1)), rest]. |
|
1799 |
|
1800 (string at:idx) == $& ifTrue:[idx := idx + 1] |
|
1801 ifFalse:[pos := idx]. |
|
1802 size := size - 1. |
|
1803 ] |
|
1804 ] |
|
1805 ]. |
|
1806 size ~~ 0 ifTrue:[ |
|
1807 pos == 0 ifTrue:[ |
|
1808 pos := 1 |
|
1809 ] ifFalse:[ |
|
1810 string isText ifFalse:[ |
|
1811 string := Text string:string |
|
1812 ]. |
|
1813 string emphasisAt:pos add:#underline |
|
1814 ]. |
|
1815 accessCharacter := (string at:pos) asLowercase |
|
1816 ] ifFalse:[ |
|
1817 accessCharacter := nil |
|
1818 ]. |
|
1819 ^ string |
|
1820 ! ! |
|
1821 |
1804 !NoteBookView::Tab methodsFor:'testing'! |
1822 !NoteBookView::Tab methodsFor:'testing'! |
1805 |
1823 |
1806 containsPointX:x y:y |
1824 containsPointX:x y:y |
1807 "return true, if the point defined by x@y is contained in the tab. |
1825 "return true, if the point defined by x@y is contained in the tab. |
1808 " |
1826 " |