WGroup.st
changeset 2506 221b75206a75
parent 2497 02fee09cb896
child 2507 daaf44f27cdd
equal deleted inserted replaced
2505:b17657563552 2506:221b75206a75
    11 "
    11 "
    12 
    12 
    13 Object subclass:#WindowGroup
    13 Object subclass:#WindowGroup
    14 	instanceVariableNames:'views topViews myProcess mySensor isModal previousGroup focusView
    14 	instanceVariableNames:'views topViews myProcess mySensor isModal previousGroup focusView
    15 		focusSequence preEventHook postEventHook pointerView
    15 		focusSequence preEventHook postEventHook pointerView
    16 		isForModalSubview focusByTab'
    16 		isForModalSubview focusByTab groupHasFocus'
    17 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal
    17 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal
    18 		WindowGroupQuerySignal LastEventQuerySignal'
    18 		WindowGroupQuerySignal LastEventQuerySignal FocusViewPerDisplay'
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-Support'
    20 	category:'Interface-Support'
    21 !
    21 !
    22 
    22 
    23 !WindowGroup class methodsFor:'documentation'!
    23 !WindowGroup class methodsFor:'documentation'!
   138         focusByTab              if focus came via tabbing 
   138         focusByTab              if focus came via tabbing 
   139                                 (as opposed to an implicit focus change)
   139                                 (as opposed to an implicit focus change)
   140                                 
   140                                 
   141         focusSequence           defines the focus sequence
   141         focusSequence           defines the focus sequence
   142 
   142 
       
   143         preEventHook            if non-nil, that one gets notified of incoming
       
   144                                 events BEFORE an event is dispatched.
       
   145                                 May eat events (i.e. suppress dispatch)
       
   146                                 (hook for event filters or recorders)
       
   147 
       
   148         postEventHook           if non-nil, that one gets notified
       
   149                                 AFTER an event was dispatched.
       
   150 
       
   151         isForModalSubView
       
   152 
       
   153         groupHasFocus           true, if this windowGroup has the focus
       
   154 
   143 
   155 
   144     [class variables:]
   156     [class variables:]
   145         LeaveSignal             if raised, a modal box leaves (closes)
   157         LeaveSignal             if raised, a modal box leaves (closes)
   146 
   158 
   147         WindowGroupQuerySignal  to ask for the current windowGroup,
   159         WindowGroupQuerySignal  to ask for the current windowGroup,
   155                                 The raise returns nil, if you did not arrive
   167                                 The raise returns nil, if you did not arrive
   156                                 there due to an event.
   168                                 there due to an event.
   157                                 (i.e. ev := WindowGroup lastEventQuerySignal raise)
   169                                 (i.e. ev := WindowGroup lastEventQuerySignal raise)
   158                                 The event can be asked for the view, the type
   170                                 The event can be asked for the view, the type
   159                                 of event, x/y position etc.
   171                                 of event, x/y position etc.
       
   172 
       
   173         FocusViewPerDisplay     the view which has the focus (global - per display).
       
   174 
   160 
   175 
   161     (*) 
   176     (*) 
   162         due to historic reasons, many views have the controller functionality
   177         due to historic reasons, many views have the controller functionality
   163         integrated, and handle events themself. The windowSensor takes care
   178         integrated, and handle events themself. The windowSensor takes care
   164         of this, by checking if a view has a controller, and, if so, forwarding 
   179         of this, by checking if a view has a controller, and, if so, forwarding 
   186 
   201 
   187 !WindowGroup class methodsFor:'initialization'!
   202 !WindowGroup class methodsFor:'initialization'!
   188 
   203 
   189 initialize
   204 initialize
   190     LeaveSignal isNil ifTrue:[
   205     LeaveSignal isNil ifTrue:[
   191 	LeaveSignal := (Signal new) mayProceed:true.
   206         LeaveSignal := (Signal new) mayProceed:true.
   192 	LeaveSignal nameClass:self message:#leaveSignal.
   207         LeaveSignal nameClass:self message:#leaveSignal.
   193 	LeaveSignal notifierString:'unhandled leave signal'.
   208         LeaveSignal notifierString:'unhandled leave signal'.
   194 
   209 
   195 	WindowGroupQuerySignal := QuerySignal new.
   210         WindowGroupQuerySignal := QuerySignal new.
   196 	WindowGroupQuerySignal nameClass:self message:#windowGroupQuerySignal.
   211         WindowGroupQuerySignal nameClass:self message:#windowGroupQuerySignal.
   197 	WindowGroupQuerySignal notifierString:'query for windowgroup'.
   212         WindowGroupQuerySignal notifierString:'query for windowgroup'.
   198 
   213 
   199 	LastEventQuerySignal := QuerySignal new.
   214         LastEventQuerySignal := QuerySignal new.
   200 	LastEventQuerySignal nameClass:self message:#lastEventQuerySignal.
   215         LastEventQuerySignal nameClass:self message:#lastEventQuerySignal.
   201 	LastEventQuerySignal notifierString:'query for last event'.
   216         LastEventQuerySignal notifierString:'query for last event'.
   202     ].
   217     ].
       
   218 
       
   219     FocusViewPerDisplay := IdentityDictionary new.
   203 
   220 
   204     "WindowGroup initialize"
   221     "WindowGroup initialize"
   205 
   222 
   206     "Modified: 9.11.1996 / 17:00:53 / cg"
   223     "Modified: 9.11.1996 / 17:00:53 / cg"
   207 ! !
   224 ! !
  1239                                 ]
  1256                                 ]
  1240                             ]
  1257                             ]
  1241                         ].
  1258                         ].
  1242 
  1259 
  1243                         "/
  1260                         "/
  1244                         "/  buttonPress events turn off explicit focus, and revert
  1261                         "/  buttonPress events turn off explicit focus, and reverts
  1245                         "/  to implicit focus control
  1262                         "/  to implicit focus control
  1246                         "/
  1263                         "/
  1247                         (focusView notNil
  1264                         (focusView notNil
  1248                         and:[event isButtonPressEvent]) ifTrue:[
  1265                         and:[event isButtonPressEvent]) ifTrue:[
  1249                             self focusView:nil
  1266                             (evView wantsFocusWithButtonPress) ifTrue:[
       
  1267                                 self focusView:evView.
       
  1268                             ]
  1250                         ].
  1269                         ].
  1251 
  1270 
  1252                         LastActiveGroup := self.
  1271                         LastActiveGroup := self.
  1253                         LastActiveProcess := Processor activeProcess.
  1272                         LastActiveProcess := Processor activeProcess.
  1254 
  1273 
  1437 
  1456 
  1438 !WindowGroup methodsFor:'focus control'!
  1457 !WindowGroup methodsFor:'focus control'!
  1439 
  1458 
  1440 focusNext
  1459 focusNext
  1441     "give focus to the next view in the focusSequence.
  1460     "give focus to the next view in the focusSequence.
  1442      Skip invisible views."
  1461      Skip invisible & disabled widgets."
  1443 
  1462 
  1444     |index     "{ Class: SmallInteger }"
  1463     |index     "{ Class: SmallInteger }"
  1445      lastIndex "{ Class: SmallInteger }"
  1464      lastIndex "{ Class: SmallInteger }"
  1446      index0 next sequence|
  1465      index0 next sequence|
  1447 
  1466 
  1551 
  1570 
  1552     focusView := aView.
  1571     focusView := aView.
  1553     self focusPrevious
  1572     self focusPrevious
  1554 
  1573 
  1555     "Created: / 4.8.1998 / 02:43:08 / cg"
  1574     "Created: / 4.8.1998 / 02:43:08 / cg"
       
  1575 !
       
  1576 
       
  1577 focusRequestFrom:aView
       
  1578     "aView requests focus. I will grant it, if I have no explicit
       
  1579      focusView (i.e. not tabbed)"
       
  1580 
       
  1581     (focusView isNil or:[focusByTab not]) ifTrue:[
       
  1582         self focusView:aView byTab:false.
       
  1583         ^ true
       
  1584     ].
       
  1585     ^ false
  1556 !
  1586 !
  1557 
  1587 
  1558 focusSequence
  1588 focusSequence
  1559     "return my focus sequence for focusNext/focusPrevious.
  1589     "return my focus sequence for focusNext/focusPrevious.
  1560      Focus is stepped in the order in which subviews occur in
  1590      Focus is stepped in the order in which subviews occur in
  1637 !
  1667 !
  1638 
  1668 
  1639 focusView:aViewOrNil byTab:focusCameViaTab
  1669 focusView:aViewOrNil byTab:focusCameViaTab
  1640     "give focus to aViewOrNil"
  1670     "give focus to aViewOrNil"
  1641 
  1671 
       
  1672     |prevFocusView|
       
  1673 
       
  1674     prevFocusView := FocusViewPerDisplay at:self device ifAbsent:nil.
       
  1675 
       
  1676     (prevFocusView notNil 
       
  1677     and:[prevFocusView ~~ aViewOrNil]) ifTrue:[
       
  1678         prevFocusView showNoFocus:true.
       
  1679         prevFocusView hasKeyboardFocus:false.
       
  1680     ].
       
  1681     FocusViewPerDisplay at:self device put:aViewOrNil.
       
  1682 
  1642     focusView == aViewOrNil ifTrue:[
  1683     focusView == aViewOrNil ifTrue:[
  1643         focusView notNil ifTrue:[
  1684         focusView notNil ifTrue:[
  1644             focusByTab := focusCameViaTab.
  1685             focusByTab := focusCameViaTab.
  1645             focusByTab ifTrue:[
  1686             focusView showFocus:focusByTab.
  1646                 focusView showFocus:true.
  1687             aViewOrNil hasKeyboardFocus:true.
  1647             ].
       
  1648             focusView hasKeyboardFocus:true.
       
  1649         ].
  1688         ].
  1650         ^ self
  1689         ^ self
  1651     ].
  1690     ].
  1652 
  1691 
  1653     focusView notNil ifTrue:[
  1692     focusView notNil ifTrue:[
  1654         "/ lost explicit focus
  1693         "/ lost explicit focus
  1655         focusView == aViewOrNil ifTrue:[^ self].
  1694         focusView == aViewOrNil ifTrue:[
  1656         focusView showNoFocus:true.
  1695             aViewOrNil hasKeyboardFocus:true.
  1657     ] ifFalse:[
  1696             ^ self
  1658         pointerView notNil ifTrue:[
       
  1659             pointerView ~~ aViewOrNil ifTrue:[
       
  1660                 "/ lost implicit focus
       
  1661                 pointerView showNoFocus:false
       
  1662             ]
       
  1663         ].
  1697         ].
  1664     ].
  1698     ].
  1665 
  1699 
  1666     focusView := aViewOrNil.
  1700     focusView := aViewOrNil.
  1667     focusView notNil ifTrue:[
  1701     focusView notNil ifTrue:[
  1668         "/ got explicit focus
  1702         "/ got explicit focus
  1669         focusByTab := focusCameViaTab.
  1703         focusByTab := focusCameViaTab.
  1670         focusByTab ifTrue:[
  1704         focusByTab ifTrue:[
  1671             focusView showFocus:true.
  1705             aViewOrNil showFocus:true.
  1672         ].
  1706         ].
  1673         focusView hasKeyboardFocus:true.
  1707         aViewOrNil hasKeyboardFocus:true.
  1674     ].
  1708     ].
  1675 
  1709 
  1676     "
  1710     "
  1677      |top v1 v2|
  1711      |top v1 v2|
  1678 
  1712 
  1953 ! !
  1987 ! !
  1954 
  1988 
  1955 !WindowGroup class methodsFor:'documentation'!
  1989 !WindowGroup class methodsFor:'documentation'!
  1956 
  1990 
  1957 version
  1991 version
  1958     ^ '$Header: /cvs/stx/stx/libview/Attic/WGroup.st,v 1.157 1999-03-11 00:42:04 cg Exp $'
  1992     ^ '$Header: /cvs/stx/stx/libview/Attic/WGroup.st,v 1.158 1999-03-14 12:59:42 cg Exp $'
  1959 ! !
  1993 ! !
  1960 WindowGroup initialize!
  1994 WindowGroup initialize!