NoteBookView.st
changeset 1677 f5a30ef6a195
parent 1672 31dcb579f88a
child 1678 db691e5dba83
equal deleted inserted replaced
1676:d01663a2356d 1677:f5a30ef6a195
   723         ].
   723         ].
   724         self selection:index
   724         self selection:index
   725     ]
   725     ]
   726 !
   726 !
   727 
   727 
       
   728 processShortcutKeyEvent:event
       
   729     ^ self processShortcutKey:(event key)
       
   730 !
       
   731 
   728 sizeChanged:how
   732 sizeChanged:how
   729     "size of view changed 
   733     "size of view changed 
   730     "
   734     "
   731     super sizeChanged:how.
   735     super sizeChanged:how.
   732 
   736 
  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     "
  1831 ! !
  1849 ! !
  1832 
  1850 
  1833 !NoteBookView class methodsFor:'documentation'!
  1851 !NoteBookView class methodsFor:'documentation'!
  1834 
  1852 
  1835 version
  1853 version
  1836     ^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.27 2000-02-03 09:38:28 ca Exp $'
  1854     ^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.28 2000-02-04 10:08:39 ca Exp $'
  1837 ! !
  1855 ! !