TopView.st
changeset 5720 4c3aa29fff39
parent 5719 014212ef8765
child 5721 c183558179c4
equal deleted inserted replaced
5719:014212ef8765 5720:4c3aa29fff39
     1 "
     1 "
     2  COPYRIGHT (c) 1995 by Claus Gittinger
     2  COPYRIGHT (c) 1995 by Claus Gittinger
     3 	      All Rights Reserved
     3               All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     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
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libview' }"
    12 "{ Package: 'stx:libview' }"
    13 
    13 
    14 View subclass:#TopView
    14 View subclass:#TopView
    15 	instanceVariableNames:'type iconified keyboardProcessor'
    15         instanceVariableNames:'type iconified keyboardProcessor'
    16 	classVariableNames:'TakeFocusWhenMapped ForceModalBoxesToOpenAtCenter
    16         classVariableNames:'TakeFocusWhenMapped ForceModalBoxesToOpenAtCenter
    17 		ForceModalBoxesToOpenAtPointer MasterSlaveMask WindowTypeMask
    17                 ForceModalBoxesToOpenAtPointer MasterSlaveMask WindowTypeMask
    18 		TypeMaster TypeSlave TypePartner TypeDialog TypePopUp
    18                 TypeMaster TypeSlave TypePartner TypeDialog TypePopUp
    19 		TypeUndecorated TypeToolWindow TypeToolDialog MDIClientMask
    19                 TypeUndecorated TypeToolWindow TypeToolDialog MDIClientMask
    20 		MDIClient TypeScreenDialog CurrentWindowMoved
    20                 MDIClient TypeScreenDialog CurrentWindowMoveStart
    21 		CurrentWindowMoveStart CurrentWindowMoveState'
    21                 CurrentWindowMoveState CurrentWindowBeingMoved'
    22 	poolDictionaries:''
    22         poolDictionaries:''
    23 	category:'Views-Basic'
    23         category:'Views-Basic'
    24 !
    24 !
    25 
    25 
    26 !TopView class methodsFor:'documentation'!
    26 !TopView class methodsFor:'documentation'!
    27 
    27 
    28 copyright
    28 copyright
    29 "
    29 "
    30  COPYRIGHT (c) 1995 by Claus Gittinger
    30  COPYRIGHT (c) 1995 by Claus Gittinger
    31 	      All Rights Reserved
    31               All Rights Reserved
    32 
    32 
    33  This software is furnished under a license and may be used
    33  This software is furnished under a license and may be used
    34  only in accordance with the terms of that license and with the
    34  only in accordance with the terms of that license and with the
    35  inclusion of the above copyright notice.   This software may not
    35  inclusion of the above copyright notice.   This software may not
    36  be provided or otherwise made available to, or used by, any
    36  be provided or otherwise made available to, or used by, any
    46 
    46 
    47     Do not get confused by the name TopView - your applications
    47     Do not get confused by the name TopView - your applications
    48     topViews are typically instances of StandardSystemView.
    48     topViews are typically instances of StandardSystemView.
    49 
    49 
    50     [instance variables:]
    50     [instance variables:]
    51 	type            <Integer>       encodes master/slave relationship:
    51         type            <Integer>       encodes master/slave relationship:
    52 					    #normal, #master, #slave or #partner
    52                                             #normal, #master, #slave or #partner
    53 					for modeless views
    53                                         for modeless views
    54 					(the #master-, #slave- or #partner-type links multiple views
    54                                         (the #master-, #slave- or #partner-type links multiple views
    55 					 into a windowManagers windowGroup -> for de-iconification)
    55                                          into a windowManagers windowGroup -> for de-iconification)
    56 
    56 
    57 					encodes window type:
    57                                         encodes window type:
    58 					    #normal, #dialog, #popup, #undecorated
    58                                             #normal, #dialog, #popup, #undecorated
    59 
    59 
    60     [see also:]
    60     [see also:]
    61 	StandardSystemView PopUpView DialogBox
    61         StandardSystemView PopUpView DialogBox
    62 	( introduction to view programming :html: programming/viewintro.html )
    62         ( introduction to view programming :html: programming/viewintro.html )
    63 
    63 
    64     [author:]
    64     [author:]
    65 	Claus Gittinger
    65         Claus Gittinger
    66 "
    66 "
    67 !
    67 !
    68 
    68 
    69 examples
    69 examples
    70 "
    70 "
    74 
    74 
    75   The bahavior is controlled by ST/X, and controlled by the open vs. openModeless vs. openModal message.
    75   The bahavior is controlled by ST/X, and controlled by the open vs. openModeless vs. openModal message.
    76 
    76 
    77   Modeless:
    77   Modeless:
    78     regular style:
    78     regular style:
    79 							    [exBegin]
    79                                                             [exBegin]
    80 	|v|
    80         |v|
    81 
    81 
    82 	v := TopView new.
    82         v := TopView new.
    83 	v extent:200@200.
    83         v extent:200@200.
    84 	v open
    84         v open
    85 							    [exEnd]
    85                                                             [exEnd]
    86 
    86 
    87     dialog:
    87     dialog:
    88 							    [exBegin]
    88                                                             [exBegin]
    89 	|v|
    89         |v|
    90 
    90 
    91 	v := TopView new.
    91         v := TopView new.
    92 	v beDialogView.
    92         v beDialogView.
    93 	v extent:200@200.
    93         v extent:200@200.
    94 	v open
    94         v open
    95 	Delay waitForSeconds:10. v destroy.
    95         Delay waitForSeconds:10. v destroy.
    96 							    [exEnd]
    96                                                             [exEnd]
    97 
    97 
    98     popUp (always on top):
    98     popUp (always on top):
    99 							    [exBegin]
    99                                                             [exBegin]
   100 	|v|
   100         |v|
   101 
   101 
   102 	v := TopView new.
   102         v := TopView new.
   103 	v bePopUpView.
   103         v bePopUpView.
   104 	v extent:200@200.
   104         v extent:200@200.
   105 	v open.
   105         v open.
   106 	Delay waitForSeconds:10. v destroy.
   106         Delay waitForSeconds:10. v destroy.
   107 							    [exEnd]
   107                                                             [exEnd]
   108 
   108 
   109     undecorated (looks loke popUp, but is not always on top):
   109     undecorated (looks loke popUp, but is not always on top):
   110 							    [exBegin]
   110                                                             [exBegin]
   111 	|v|
   111         |v|
   112 
   112 
   113 	v := TopView new.
   113         v := TopView new.
   114 	v beUndecorated.
   114         v beUndecorated.
   115 	v extent:200@200.
   115         v extent:200@200.
   116 	v open.
   116         v open.
   117 	Delay waitForSeconds:10. v destroy.
   117         Delay waitForSeconds:10. v destroy.
   118 							    [exEnd]
   118                                                             [exEnd]
   119 
   119 
   120     toolwindow (looks loke normal, but has smaller windowTitle-area on win32):
   120     toolwindow (looks loke normal, but has smaller windowTitle-area on win32):
   121 							    [exBegin]
   121                                                             [exBegin]
   122 	|v|
   122         |v|
   123 
   123 
   124 	v := TopView new.
   124         v := TopView new.
   125 	v beToolWindow.
   125         v beToolWindow.
   126 	v extent:200@200.
   126         v extent:200@200.
   127 	v open.
   127         v open.
   128 	Delay waitForSeconds:10. v destroy.
   128         Delay waitForSeconds:10. v destroy.
   129 							    [exEnd]
   129                                                             [exEnd]
   130 
   130 
   131     toolwindow dialog (looks loke normal, but has smaller windowTitle-area on win32):
   131     toolwindow dialog (looks loke normal, but has smaller windowTitle-area on win32):
   132 							    [exBegin]
   132                                                             [exBegin]
   133 	|v|
   133         |v|
   134 
   134 
   135 	v := TopView new.
   135         v := TopView new.
   136 	v beToolDialog.
   136         v beToolDialog.
   137 	v extent:200@200.
   137         v extent:200@200.
   138 	v open.
   138         v open.
   139 	Delay waitForSeconds:10. v destroy.
   139         Delay waitForSeconds:10. v destroy.
   140 							    [exEnd]
   140                                                             [exEnd]
   141 
   141 
   142   Modal:
   142   Modal:
   143     regular style:
   143     regular style:
   144 							    [exBegin]
   144                                                             [exBegin]
   145 	|v|
   145         |v|
   146 
   146 
   147 	v := TopView new.
   147         v := TopView new.
   148 	v extent:200@200.
   148         v extent:200@200.
   149 	v openModal
   149         v openModal
   150 							    [exEnd]
   150                                                             [exEnd]
   151 
   151 
   152     dialog:
   152     dialog:
   153 							    [exBegin]
   153                                                             [exBegin]
   154 	|v|
   154         |v|
   155 
   155 
   156 	v := TopView new.
   156         v := TopView new.
   157 	v beDialogView.
   157         v beDialogView.
   158 	v extent:200@200.
   158         v extent:200@200.
   159 	v openModal
   159         v openModal
   160 							    [exEnd]
   160                                                             [exEnd]
   161 
   161 
   162     popUp (always on top):
   162     popUp (always on top):
   163 							    [exBegin]
   163                                                             [exBegin]
   164 	|v|
   164         |v|
   165 
   165 
   166 	v := TopView new.
   166         v := TopView new.
   167 	v bePopUpView.
   167         v bePopUpView.
   168 	v extent:200@200.
   168         v extent:200@200.
   169 	v openModal
   169         v openModal
   170 							    [exEnd]
   170                                                             [exEnd]
   171 
   171 
   172     undecorated (looks loke popUp, but is not always on top):
   172     undecorated (looks loke popUp, but is not always on top):
   173 							    [exBegin]
   173                                                             [exBegin]
   174 	|v|
   174         |v|
   175 
   175 
   176 	v := TopView new.
   176         v := TopView new.
   177 	v beUndecorated.
   177         v beUndecorated.
   178 	v extent:200@200.
   178         v extent:200@200.
   179 	v openModal
   179         v openModal
   180 							    [exEnd]
   180                                                             [exEnd]
   181 
   181 
   182 "
   182 "
       
   183 ! !
       
   184 
       
   185 !TopView class methodsFor:'accessing'!
       
   186 
       
   187 currentWindowBeingMoved
       
   188     "the current window move operation 
       
   189      (only used with modeless popup windows; i.e. windows without decoration,
       
   190       which want to be moved by click-motion on the background)"
       
   191 
       
   192     ^ CurrentWindowBeingMoved
       
   193 
       
   194     "Created: / 03-03-2011 / 19:20:34 / cg"
   183 ! !
   195 ! !
   184 
   196 
   185 !TopView class methodsFor:'class initialization'!
   197 !TopView class methodsFor:'class initialization'!
   186 
   198 
   187 initialize
   199 initialize
   214 
   226 
   215     |display|
   227     |display|
   216 
   228 
   217     display := Screen current.
   229     display := Screen current.
   218     display isNil ifTrue:[
   230     display isNil ifTrue:[
   219 	^ 600 @ 400
   231         ^ 600 @ 400
   220     ].
   232     ].
   221     ^ display defaultExtentForTopViews
   233     ^ display defaultExtentForTopViews
   222 !
   234 !
   223 
   235 
   224 forceModalBoxesToOpenAtCenter
   236 forceModalBoxesToOpenAtCenter
   309 beDialogView
   321 beDialogView
   310     "make me a Dialog Window; that is one which raises above all other ST/X views"
   322     "make me a Dialog Window; that is one which raises above all other ST/X views"
   311 
   323 
   312     "/ the nonInteger handling code is for backward compatibility only.
   324     "/ the nonInteger handling code is for backward compatibility only.
   313     type isInteger ifTrue:[
   325     type isInteger ifTrue:[
   314 	type := (type bitClear:WindowTypeMask) bitOr:TypeDialog.
   326         type := (type bitClear:WindowTypeMask) bitOr:TypeDialog.
   315 	^ self.
   327         ^ self.
   316     ].
   328     ].
   317     type := #dialog
   329     type := #dialog
   318 !
   330 !
   319 
   331 
   320 beIndependent
   332 beIndependent
   322      attribute (this is the default).
   334      attribute (this is the default).
   323      However, the view remains in the current windowGroup"
   335      However, the view remains in the current windowGroup"
   324 
   336 
   325     "/ the nonInteger handling code is for backward compatibility only.
   337     "/ the nonInteger handling code is for backward compatibility only.
   326     type isInteger ifTrue:[
   338     type isInteger ifTrue:[
   327 	type := type bitClear:MasterSlaveMask.
   339         type := type bitClear:MasterSlaveMask.
   328 	^ self.
   340         ^ self.
   329     ].
   341     ].
   330     type := nil
   342     type := nil
   331 !
   343 !
   332 
   344 
   333 beMDIClientView
   345 beMDIClientView
   340      and also de/iconify together with their master(s).
   352      and also de/iconify together with their master(s).
   341      (i.e. they follow their master(s))."
   353      (i.e. they follow their master(s))."
   342 
   354 
   343     "/ the nonInteger handling code is for backward compatibility only.
   355     "/ the nonInteger handling code is for backward compatibility only.
   344     type isInteger ifTrue:[
   356     type isInteger ifTrue:[
   345 	type := (type bitClear:MasterSlaveMask) bitOr:TypeMaster.
   357         type := (type bitClear:MasterSlaveMask) bitOr:TypeMaster.
   346 	^ self.
   358         ^ self.
   347     ].
   359     ].
   348     type := #master
   360     type := #master
   349 
   361 
   350     "
   362     "
   351      see example in TopView>>beSlave
   363      see example in TopView>>beSlave
   358     "make this a partner-view. Each partner-view will automatically
   370     "make this a partner-view. Each partner-view will automatically
   359      close other partner views (within the same windowGroup) when closed."
   371      close other partner views (within the same windowGroup) when closed."
   360 
   372 
   361     "/ the nonInteger handling code is for backward compatibility only.
   373     "/ the nonInteger handling code is for backward compatibility only.
   362     type isInteger ifTrue:[
   374     type isInteger ifTrue:[
   363 	type := (type bitClear:MasterSlaveMask) bitOr:TypePartner.
   375         type := (type bitClear:MasterSlaveMask) bitOr:TypePartner.
   364 	^ self.
   376         ^ self.
   365     ].
   377     ].
   366     type := #partner
   378     type := #partner
   367 
   379 
   368     "
   380     "
   369      create two topViews within the same group:
   381      create two topViews within the same group:
   385 !
   397 !
   386 
   398 
   387 bePopUpView
   399 bePopUpView
   388     "/ the nonInteger handling code is for backward compatibility only.
   400     "/ the nonInteger handling code is for backward compatibility only.
   389     type isInteger ifTrue:[
   401     type isInteger ifTrue:[
   390 	type := (type bitClear:WindowTypeMask) bitOr:TypePopUp.
   402         type := (type bitClear:WindowTypeMask) bitOr:TypePopUp.
   391 	^ self.
   403         ^ self.
   392     ].
   404     ].
   393     type := #popup
   405     type := #popup
   394 !
   406 !
   395 
   407 
   396 bePopUpViewNotModal
   408 bePopUpViewNotModal
   408     "make me a Screen-Dialog Window; that is one which raises above ALL other windows
   420     "make me a Screen-Dialog Window; that is one which raises above ALL other windows
   409      (not only st/x ones)"
   421      (not only st/x ones)"
   410 
   422 
   411     "/ the nonInteger handling code is for backward compatibility only.
   423     "/ the nonInteger handling code is for backward compatibility only.
   412     type isInteger ifTrue:[
   424     type isInteger ifTrue:[
   413 	type := (type bitClear:WindowTypeMask) bitOr:TypeScreenDialog.
   425         type := (type bitClear:WindowTypeMask) bitOr:TypeScreenDialog.
   414 	^ self.
   426         ^ self.
   415     ].
   427     ].
   416     type := #dialog
   428     type := #dialog
   417 !
   429 !
   418 
   430 
   419 beSlave
   431 beSlave
   421      whenever any master of the windowgroup is closed.
   433      whenever any master of the windowgroup is closed.
   422      See also: #bePartner"
   434      See also: #bePartner"
   423 
   435 
   424     "/ the nonInteger handling code is for backward compatibility only.
   436     "/ the nonInteger handling code is for backward compatibility only.
   425     type isInteger ifTrue:[
   437     type isInteger ifTrue:[
   426 	type := (type bitClear:MasterSlaveMask) bitOr:TypeSlave.
   438         type := (type bitClear:MasterSlaveMask) bitOr:TypeSlave.
   427 	^ self.
   439         ^ self.
   428     ].
   440     ].
   429     type := #slave
   441     type := #slave
   430 
   442 
   431     "
   443     "
   432      create two topViews within the same group:
   444      create two topViews within the same group:
   449 !
   461 !
   450 
   462 
   451 beToolDialog
   463 beToolDialog
   452     "/ the nonInteger handling code is for backward compatibility only.
   464     "/ the nonInteger handling code is for backward compatibility only.
   453     type isInteger ifTrue:[
   465     type isInteger ifTrue:[
   454 	type := (type bitClear:WindowTypeMask) bitOr:TypeToolDialog.
   466         type := (type bitClear:WindowTypeMask) bitOr:TypeToolDialog.
   455 	^ self.
   467         ^ self.
   456     ].
   468     ].
   457     type := #dialog
   469     type := #dialog
   458 !
   470 !
   459 
   471 
   460 beToolWindow
   472 beToolWindow
   461     "/ the nonInteger handling code is for backward compatibility only.
   473     "/ the nonInteger handling code is for backward compatibility only.
   462     type isInteger ifTrue:[
   474     type isInteger ifTrue:[
   463 	type := (type bitClear:WindowTypeMask) bitOr:TypeToolWindow.
   475         type := (type bitClear:WindowTypeMask) bitOr:TypeToolWindow.
   464 	^ self.
   476         ^ self.
   465     ].
   477     ].
   466     type := nil
   478     type := nil
   467 !
   479 !
   468 
   480 
   469 beUndecorated
   481 beUndecorated
   470     "make me an undecorated Window"
   482     "make me an undecorated Window"
   471 
   483 
   472     "/ the nonInteger handling code is for backward compatibility only.
   484     "/ the nonInteger handling code is for backward compatibility only.
   473     type isInteger ifTrue:[
   485     type isInteger ifTrue:[
   474 	type := (type bitClear:WindowTypeMask) bitOr:TypeUndecorated.
   486         type := (type bitClear:WindowTypeMask) bitOr:TypeUndecorated.
   475 	^ self.
   487         ^ self.
   476     ].
   488     ].
   477     type := nil
   489     type := nil
   478 !
   490 !
   479 
   491 
   480 focusSequence:aCollectionOfSubcomponents
   492 focusSequence:aCollectionOfSubcomponents
   481     "define the sequence for stepping through my components."
   493     "define the sequence for stepping through my components."
   482 
   494 
   483     windowGroup isNil ifTrue:[
   495     windowGroup isNil ifTrue:[
   484 	windowGroup := self windowGroupClass new.
   496         windowGroup := self windowGroupClass new.
   485     ].
   497     ].
   486     windowGroup focusSequence:aCollectionOfSubcomponents.
   498     windowGroup focusSequence:aCollectionOfSubcomponents.
   487 
   499 
   488     "Created: 6.3.1996 / 15:37:11 / cg"
   500     "Created: 6.3.1996 / 15:37:11 / cg"
   489     "Modified: 30.4.1996 / 15:41:40 / cg"
   501     "Modified: 30.4.1996 / 15:41:40 / cg"
   504 addTrayIcon:anImageOrForm toolTipMessage:toolTipMessage
   516 addTrayIcon:anImageOrForm toolTipMessage:toolTipMessage
   505     "WIN32 only: add a tray icon for myself;
   517     "WIN32 only: add a tray icon for myself;
   506      may then receive tray*-events in the future."
   518      may then receive tray*-events in the future."
   507 
   519 
   508     self device
   520     self device
   509 	 addTrayIconFor:self
   521          addTrayIconFor:self
   510 	 icon:anImageOrForm iconMask:nil
   522          icon:anImageOrForm iconMask:nil
   511 	 toolTipMessage:toolTipMessage
   523          toolTipMessage:toolTipMessage
   512 
   524 
   513     "
   525     "
   514      |v icon|
   526      |v icon|
   515 
   527 
   516      v := StandardSystemView new.
   528      v := StandardSystemView new.
   528 keyPress:key x:x y:y
   540 keyPress:key x:x y:y
   529     "notice: this ought to be moved into the upcoming
   541     "notice: this ought to be moved into the upcoming
   530      StandardSystemViewController."
   542      StandardSystemViewController."
   531 
   543 
   532     <resource: #keyboard ( #Tab
   544     <resource: #keyboard ( #Tab
   533 			   #FocusNext #FocusPrevious
   545                            #FocusNext #FocusPrevious
   534 			   #CursorDown #CursorUp ) >
   546                            #CursorDown #CursorUp ) >
   535 
   547 
   536     windowGroup notNil ifTrue:[
   548     windowGroup notNil ifTrue:[
   537 	key == #Tab ifTrue:[
   549         key == #Tab ifTrue:[
   538 	    self sensor shiftDown ifTrue:[
   550             self sensor shiftDown ifTrue:[
   539 		windowGroup focusPrevious
   551                 windowGroup focusPrevious
   540 	    ] ifFalse:[
   552             ] ifFalse:[
   541 		windowGroup focusNext
   553                 windowGroup focusNext
   542 	    ].
   554             ].
   543 	    ^ self.
   555             ^ self.
   544 	].
   556         ].
   545 	(key == #FocusNext or:[key == #CursorDown]) ifTrue:[
   557         (key == #FocusNext or:[key == #CursorDown]) ifTrue:[
   546 	    windowGroup focusNext.
   558             windowGroup focusNext.
   547 	    ^ self.
   559             ^ self.
   548 	].
   560         ].
   549 	(key == #FocusPrevious or:[key == #CursorUp])  ifTrue:[
   561         (key == #FocusPrevious or:[key == #CursorUp])  ifTrue:[
   550 	    windowGroup focusPrevious.
   562             windowGroup focusPrevious.
   551 	    ^ self.
   563             ^ self.
   552 	].
   564         ].
   553     ].
   565     ].
   554 
   566 
   555     super keyPress:key x:x y:y
   567     super keyPress:key x:x y:y
   556 
   568 
   557     "Created: / 01-02-1996 / 22:08:30 / cg"
   569     "Created: / 01-02-1996 / 22:08:30 / cg"
   604 
   616 
   605     ^ self
   617     ^ self
   606 
   618 
   607     "Created: / 31-10-2007 / 01:25:33 / cg"
   619     "Created: / 31-10-2007 / 01:25:33 / cg"
   608     "Modified: / 05-11-2007 / 12:11:17 / cg"
   620     "Modified: / 05-11-2007 / 12:11:17 / cg"
       
   621 ! !
       
   622 
       
   623 !TopView methodsFor:'event handling-window move'!
       
   624 
       
   625 doWindowMove
       
   626     "a window move operation 
       
   627      (only used with modeless popup windows; i.e. windows without decoration,
       
   628       which want to be moved by click-motion on the background)"
       
   629 
       
   630     |delta|
       
   631 
       
   632     CurrentWindowBeingMoved == self ifTrue:[
       
   633         delta := device pointerPosition - CurrentWindowMoveStart.
       
   634         (CurrentWindowMoveState notNil
       
   635         or:[ delta r > 5 ]) ifTrue:[
       
   636             CurrentWindowMoveState := #inMove.
       
   637             CurrentWindowMoveStart := device pointerPosition.
       
   638             self origin:(self origin + delta).
       
   639         ].
       
   640     ].
       
   641 
       
   642     "Created: / 03-03-2011 / 19:13:08 / cg"
       
   643 !
       
   644 
       
   645 endWindowMove
       
   646     "a window move operation 
       
   647      (only used with modeless popup windows; i.e. windows without decoration,
       
   648       which want to be moved by click-motion on the background)"
       
   649 
       
   650     CurrentWindowBeingMoved := nil.
       
   651 
       
   652     "Created: / 03-03-2011 / 19:17:24 / cg"
       
   653 !
       
   654 
       
   655 startWindowMove
       
   656     "a window move operation 
       
   657      (only used with modeless popup windows; i.e. windows without decoration,
       
   658       which want to be moved by click-motion on the background)"
       
   659 
       
   660     CurrentWindowBeingMoved := self.
       
   661     CurrentWindowMoveStart := device pointerPosition.
       
   662     CurrentWindowMoveState := nil.
       
   663 
       
   664     "Created: / 03-03-2011 / 19:09:39 / cg"
   609 ! !
   665 ! !
   610 
   666 
   611 !TopView methodsFor:'help'!
   667 !TopView methodsFor:'help'!
   612 
   668 
   613 flyByHelpDependsOnPositionIn:aView
   669 flyByHelpDependsOnPositionIn:aView
   663 "/        ]
   719 "/        ]
   664 "/    ].
   720 "/    ].
   665 
   721 
   666     (windowGroup notNil
   722     (windowGroup notNil
   667     and:[(componentWithInitialFocus := windowGroup defaultKeyboardConsumer) notNil]) ifTrue:[
   723     and:[(componentWithInitialFocus := windowGroup defaultKeyboardConsumer) notNil]) ifTrue:[
   668 	windowGroup focusView:componentWithInitialFocus byTab:true "false".
   724         windowGroup focusView:componentWithInitialFocus byTab:true "false".
   669     ] ifFalse:[
   725     ] ifFalse:[
   670 	self assignKeyboardFocusToFirstInputField.
   726         self assignKeyboardFocusToFirstInputField.
   671     ].
   727     ].
   672 !
   728 !
   673 
   729 
   674 assignKeyboardFocusToFirstInputField
   730 assignKeyboardFocusToFirstInputField
   675     "assign the keyboard focus to the first first keyboardConsumer.
   731     "assign the keyboard focus to the first first keyboardConsumer.
   677       see (or redefine) preferFirstInputFieldWhenAssigningInitialFocus)"
   733       see (or redefine) preferFirstInputFieldWhenAssigningInitialFocus)"
   678 
   734 
   679     |firstInputField firstConsumer firstCursorConsumer consumer|
   735     |firstInputField firstConsumer firstCursorConsumer consumer|
   680 
   736 
   681     self allSubViewsDo:[:v |
   737     self allSubViewsDo:[:v |
   682 	(firstInputField isNil and:[v isInputField]) ifTrue:[
   738         (firstInputField isNil and:[v isInputField]) ifTrue:[
   683 	    firstInputField := v
   739             firstInputField := v
   684 	].
   740         ].
   685 	(firstConsumer isNil and:[v isKeyboardConsumer]) ifTrue:[
   741         (firstConsumer isNil and:[v isKeyboardConsumer]) ifTrue:[
   686 	    firstConsumer := v
   742             firstConsumer := v
   687 	].
   743         ].
   688 	(firstCursorConsumer isNil and:[v isCursorKeyConsumer]) ifTrue:[
   744         (firstCursorConsumer isNil and:[v isCursorKeyConsumer]) ifTrue:[
   689 	    firstCursorConsumer := v
   745             firstCursorConsumer := v
   690 	].
   746         ].
   691     ].
   747     ].
   692     self preferFirstInputFieldWhenAssigningInitialFocus ifTrue:[
   748     self preferFirstInputFieldWhenAssigningInitialFocus ifTrue:[
   693 	consumer := firstInputField.
   749         consumer := firstInputField.
   694     ].
   750     ].
   695     consumer := (consumer ? firstConsumer ? firstCursorConsumer).
   751     consumer := (consumer ? firstConsumer ? firstCursorConsumer).
   696     consumer notNil ifTrue:[
   752     consumer notNil ifTrue:[
   697 	device platformName = 'WIN32' ifTrue:[
   753         device platformName = 'WIN32' ifTrue:[
   698 	    self windowGroup focusView:consumer byTab:true.
   754             self windowGroup focusView:consumer byTab:true.
   699 	] ifFalse:[
   755         ] ifFalse:[
   700 	    consumer requestFocus.
   756             consumer requestFocus.
   701 	    "/ consumer requestFocus. - could be denied; but we force it here
   757             "/ consumer requestFocus. - could be denied; but we force it here
   702 	    windowGroup focusView:consumer byTab:false.
   758             windowGroup focusView:consumer byTab:false.
   703 	].
   759         ].
   704     ].
   760     ].
   705 
   761 
   706     "Modified: / 29-08-2006 / 14:32:30 / cg"
   762     "Modified: / 29-08-2006 / 14:32:30 / cg"
   707 !
   763 !
   708 
   764 
   749 
   805 
   750 postRealize
   806 postRealize
   751     super postRealize.
   807     super postRealize.
   752 
   808 
   753     keyboardProcessor isNil ifTrue:[
   809     keyboardProcessor isNil ifTrue:[
   754 	keyboardProcessor := KeyboardProcessor new.
   810         keyboardProcessor := KeyboardProcessor new.
   755     ].
   811     ].
   756 
   812 
   757     device realizedTopViewHookFor:self
   813     device realizedTopViewHookFor:self
   758 !
   814 !
   759 
   815 
   760 realize
   816 realize
   761     self isMarkedAsUnmappedModalBox ifTrue:[
   817     self isMarkedAsUnmappedModalBox ifTrue:[
   762 	"/ must clear this flag
   818         "/ must clear this flag
   763 	"/ - otherwise realize thinks it is already realized.
   819         "/ - otherwise realize thinks it is already realized.
   764 	realized := false.
   820         realized := false.
   765 	self unmarkAsUnmappedModalBox.
   821         self unmarkAsUnmappedModalBox.
   766     ].
   822     ].
   767     super realize.
   823     super realize.
   768 !
   824 !
   769 
   825 
   770 release
   826 release
   771     keyboardProcessor notNil ifTrue:[
   827     keyboardProcessor notNil ifTrue:[
   772 	keyboardProcessor release.
   828         keyboardProcessor release.
   773 	keyboardProcessor := nil.
   829         keyboardProcessor := nil.
   774     ].
   830     ].
   775     super release
   831     super release
   776 ! !
   832 ! !
   777 
   833 
   778 !TopView methodsFor:'misc'!
   834 !TopView methodsFor:'misc'!
   806 raiseDeiconified
   862 raiseDeiconified
   807     "deiconify & bring to front"
   863     "deiconify & bring to front"
   808 
   864 
   809     self isCollapsed ifTrue:[
   865     self isCollapsed ifTrue:[
   810 "/        self unmap.
   866 "/        self unmap.
   811 	self realize.
   867         self realize.
   812     ].
   868     ].
   813     self raise
   869     self raise
   814 
   870 
   815     "
   871     "
   816      Transcript topView raiseDeiconified
   872      Transcript topView raiseDeiconified
   834      Can be used to synchronize multiple-window applications,
   890      Can be used to synchronize multiple-window applications,
   835      and (especially) to wait until an application session is finished
   891      and (especially) to wait until an application session is finished
   836      when invoking commands with the rDoit mechanism"
   892      when invoking commands with the rDoit mechanism"
   837 
   893 
   838     [drawableId isNil] whileFalse:[
   894     [drawableId isNil] whileFalse:[
   839 	Delay waitForSeconds:0.1.
   895         Delay waitForSeconds:0.1.
   840     ].
   896     ].
   841 
   897 
   842     "asynchronous:
   898     "asynchronous:
   843 
   899 
   844      EditTextView open
   900      EditTextView open
   855 withCursor:aCursor do:aBlock
   911 withCursor:aCursor do:aBlock
   856     "evaluate aBlock while showing aCursor in all my views.
   912     "evaluate aBlock while showing aCursor in all my views.
   857      Return the value as returned by aBlock."
   913      Return the value as returned by aBlock."
   858 
   914 
   859     windowGroup notNil ifTrue:[
   915     windowGroup notNil ifTrue:[
   860 	^ windowGroup withCursor:aCursor do:aBlock
   916         ^ windowGroup withCursor:aCursor do:aBlock
   861     ].
   917     ].
   862     ^ super withCursor:aCursor do:aBlock
   918     ^ super withCursor:aCursor do:aBlock
   863 ! !
   919 ! !
   864 
   920 
   865 !TopView methodsFor:'queries'!
   921 !TopView methodsFor:'queries'!
   898 
   954 
   899 isDialogView
   955 isDialogView
   900     "return true if this is a dialog view"
   956     "return true if this is a dialog view"
   901 
   957 
   902     type isInteger ifTrue:[
   958     type isInteger ifTrue:[
   903 	^ (type bitAnd:WindowTypeMask) == TypeDialog
   959         ^ (type bitAnd:WindowTypeMask) == TypeDialog
   904     ].
   960     ].
   905     "/ the nonInteger handling code is for backward compatibility only.
   961     "/ the nonInteger handling code is for backward compatibility only.
   906     ^ type == #dialog
   962     ^ type == #dialog
   907 !
   963 !
   908 
   964 
   912 
   968 
   913 isMaster
   969 isMaster
   914     "return true, if this is a masterView"
   970     "return true, if this is a masterView"
   915 
   971 
   916     type isInteger ifTrue:[
   972     type isInteger ifTrue:[
   917 	^ (type bitAnd:MasterSlaveMask) == TypeMaster
   973         ^ (type bitAnd:MasterSlaveMask) == TypeMaster
   918     ].
   974     ].
   919     "/ the nonInteger handling code is for backward compatibility only.
   975     "/ the nonInteger handling code is for backward compatibility only.
   920     ^ type == #master
   976     ^ type == #master
   921 !
   977 !
   922 
   978 
   929 
   985 
   930 isPartner
   986 isPartner
   931     "return true, if this is a partnerView"
   987     "return true, if this is a partnerView"
   932 
   988 
   933     type isInteger ifTrue:[
   989     type isInteger ifTrue:[
   934 	^ (type bitAnd:MasterSlaveMask) == TypePartner
   990         ^ (type bitAnd:MasterSlaveMask) == TypePartner
   935     ].
   991     ].
   936     "/ the nonInteger handling code is for backward compatibility only.
   992     "/ the nonInteger handling code is for backward compatibility only.
   937     ^ type == #partner
   993     ^ type == #partner
   938 !
   994 !
   939 
   995 
   966 
  1022 
   967 isSlave
  1023 isSlave
   968     "return true, if this is a slaveView"
  1024     "return true, if this is a slaveView"
   969 
  1025 
   970     type isInteger ifTrue:[
  1026     type isInteger ifTrue:[
   971 	^ (type bitAnd:MasterSlaveMask) == TypeSlave
  1027         ^ (type bitAnd:MasterSlaveMask) == TypeSlave
   972     ].
  1028     ].
   973     "/ the nonInteger handling code is for backward compatibility only.
  1029     "/ the nonInteger handling code is for backward compatibility only.
   974     ^ type == #slave
  1030     ^ type == #slave
   975 !
  1031 !
   976 
  1032 
  1026      however many subclasses redefine this to compute the actual value
  1082      however many subclasses redefine this to compute the actual value
  1027      depending on the sizes of the contents or subcomponents."
  1083      depending on the sizes of the contents or subcomponents."
  1028 
  1084 
  1029     "/ If I have an explicit preferredExtent..
  1085     "/ If I have an explicit preferredExtent..
  1030     explicitExtent notNil ifTrue:[
  1086     explicitExtent notNil ifTrue:[
  1031 	^ explicitExtent
  1087         ^ explicitExtent
  1032     ].
  1088     ].
  1033 
  1089 
  1034     "/ If I have a cached preferredExtent value..
  1090     "/ If I have a cached preferredExtent value..
  1035     preferredExtent notNil ifTrue:[
  1091     preferredExtent notNil ifTrue:[
  1036 	^ preferredExtent
  1092         ^ preferredExtent
  1037     ].
  1093     ].
  1038     ^ self class defaultExtent
  1094     ^ self class defaultExtent
  1039 
  1095 
  1040     "Modified: 19.7.1996 / 20:45:41 / cg"
  1096     "Modified: 19.7.1996 / 20:45:41 / cg"
  1041 !
  1097 !
  1052      This is used by the device as a decoration hint."
  1108      This is used by the device as a decoration hint."
  1053 
  1109 
  1054     |t|
  1110     |t|
  1055 
  1111 
  1056     type isInteger ifTrue:[
  1112     type isInteger ifTrue:[
  1057 	t := type bitAnd:WindowTypeMask.
  1113         t := type bitAnd:WindowTypeMask.
  1058 	t == TypeUndecorated ifTrue:[^ #undecorated].
  1114         t == TypeUndecorated ifTrue:[^ #undecorated].
  1059 	t == TypeDialog ifTrue:[^ #dialog].
  1115         t == TypeDialog ifTrue:[^ #dialog].
  1060 	t == TypePopUp ifTrue:[^ #popUp].
  1116         t == TypePopUp ifTrue:[^ #popUp].
  1061 	t == TypeToolWindow ifTrue:[^ #toolWindow].
  1117         t == TypeToolWindow ifTrue:[^ #toolWindow].
  1062 	t == TypeToolDialog ifTrue:[^ #toolDialog].
  1118         t == TypeToolDialog ifTrue:[^ #toolDialog].
  1063 	^ #normal
  1119         ^ #normal
  1064     ].
  1120     ].
  1065     "/ the nonInteger handling code is for backward compatibility only.
  1121     "/ the nonInteger handling code is for backward compatibility only.
  1066     ^ super windowStyle
  1122     ^ super windowStyle
  1067 ! !
  1123 ! !
  1068 
  1124 
  1070 
  1126 
  1071 openModal
  1127 openModal
  1072     "added bell to wake up user"
  1128     "added bell to wake up user"
  1073 
  1129 
  1074     (self beepWhenOpening) ifTrue:[
  1130     (self beepWhenOpening) ifTrue:[
  1075 	self beep.
  1131         self beep.
  1076     ].
  1132     ].
  1077     super openModal
  1133     super openModal
  1078 
  1134 
  1079     "
  1135     "
  1080      self warn:'hello'
  1136      self warn:'hello'
  1127     "/ by sending a closerequest always and letting popUps
  1183     "/ by sending a closerequest always and letting popUps
  1128     "/ respond by hiding ???
  1184     "/ respond by hiding ???
  1129 
  1185 
  1130     (windowGroup notNil
  1186     (windowGroup notNil
  1131     and:[ windowGroup isModal ]) ifTrue:[
  1187     and:[ windowGroup isModal ]) ifTrue:[
  1132 	masterGroup := windowGroup previousGroup.
  1188         masterGroup := windowGroup previousGroup.
  1133 	myApplication := self application.
  1189         myApplication := self application.
  1134 
  1190 
  1135 	(myApplication notNil
  1191         (myApplication notNil
  1136 	and:[ masterGroup isNil or:[myApplication ~= masterGroup application]]) ifTrue:[
  1192         and:[ masterGroup isNil or:[myApplication ~= masterGroup application]]) ifTrue:[
  1137 	    AbortOperationRequest handle:[:ex |
  1193             AbortOperationRequest handle:[:ex |
  1138 		"/ in case the close is cought by the application
  1194                 "/ in case the close is cought by the application
  1139 		^ self.
  1195                 ^ self.
  1140 	    ] do:[
  1196             ] do:[
  1141 		myApplication closeRequest.
  1197                 myApplication closeRequest.
  1142 
  1198 
  1143 		"/ if myApp called closeDownViews, it wants me to hide.
  1199                 "/ if myApp called closeDownViews, it wants me to hide.
  1144 		"/ otherwise, it has redefined closeRequest to return without closeDownViews.
  1200                 "/ otherwise, it has redefined closeRequest to return without closeDownViews.
  1145 		realized ifTrue:[
  1201                 realized ifTrue:[
  1146 		    "/ closeDownViews was not called - app wants me to remain open
  1202                     "/ closeDownViews was not called - app wants me to remain open
  1147 		    ^ self
  1203                     ^ self
  1148 		].
  1204                 ].
  1149 	    ].
  1205             ].
  1150 	].
  1206         ].
  1151     ].
  1207     ].
  1152     super hide.
  1208     super hide.
  1153 !
  1209 !
  1154 
  1210 
  1155 map
  1211 map
  1156     "make the view visible on the screen.
  1212     "make the view visible on the screen.
  1157      For topViews, the windowManager will choose (or ask for) the
  1213      For topViews, the windowManager will choose (or ask for) the
  1158      views position on the screen.
  1214      views position on the screen.
  1159      Notice:
  1215      Notice:
  1160 	Actually, this method is only valid for topViews;
  1216         Actually, this method is only valid for topViews;
  1161 	however, it is defined here to allow things like 'Button new realize'"
  1217         however, it is defined here to allow things like 'Button new realize'"
  1162 
  1218 
  1163     self mapAt:(self origin) iconified:false
  1219     self mapAt:(self origin) iconified:false
  1164 !
  1220 !
  1165 
  1221 
  1166 mapIconified
  1222 mapIconified
  1167     "make the view visible but iconified.
  1223     "make the view visible but iconified.
  1168      In contrast to map, which does it non-iconified"
  1224      In contrast to map, which does it non-iconified"
  1169 
  1225 
  1170     realized ifFalse:[
  1226     realized ifFalse:[
  1171 	"
  1227         "
  1172 	 now, make the view visible
  1228          now, make the view visible
  1173 	"
  1229         "
  1174 	realized := true.
  1230         realized := true.
  1175 	device
  1231         device
  1176 	    mapView:self id:drawableId iconified:true
  1232             mapView:self id:drawableId iconified:true
  1177 	    atX:left y:top width:width height:height
  1233             atX:left y:top width:width height:height
  1178 	    minExtent:(self minExtent) maxExtent:(self maxExtent)
  1234             minExtent:(self minExtent) maxExtent:(self maxExtent)
  1179     ]
  1235     ]
  1180 
  1236 
  1181     "Modified: 25.2.1997 / 22:44:33 / cg"
  1237     "Modified: 25.2.1997 / 22:44:33 / cg"
  1182     "Created: 24.7.1997 / 12:48:21 / cg"
  1238     "Created: 24.7.1997 / 12:48:21 / cg"
  1183 !
  1239 !
  1226 
  1282 
  1227     |otherId|
  1283     |otherId|
  1228 
  1284 
  1229     drawableId isNil ifTrue:[self create].
  1285     drawableId isNil ifTrue:[self create].
  1230     anotherView isNil ifTrue:[
  1286     anotherView isNil ifTrue:[
  1231 	otherId := drawableId.
  1287         otherId := drawableId.
  1232     ] ifFalse:[
  1288     ] ifFalse:[
  1233 	anotherView create.
  1289         anotherView create.
  1234 	otherId := anotherView id.
  1290         otherId := anotherView id.
  1235     ].
  1291     ].
  1236     device setTransient:drawableId for:otherId.
  1292     device setTransient:drawableId for:otherId.
  1237     self origin:aPosition.
  1293     self origin:aPosition.
  1238     self open
  1294     self open
  1239 
  1295 
  1284     "set origin & extent and open.
  1340     "set origin & extent and open.
  1285      The given extent overrides the receivers preferredExtent.
  1341      The given extent overrides the receivers preferredExtent.
  1286      Added for ST-80 compatibility"
  1342      Added for ST-80 compatibility"
  1287 
  1343 
  1288     self
  1344     self
  1289 	origin:aBoundaryRectangle origin;
  1345         origin:aBoundaryRectangle origin;
  1290 	extent:aBoundaryRectangle extent;
  1346         extent:aBoundaryRectangle extent;
  1291 	sizeFixed:true.
  1347         sizeFixed:true.
  1292     self open
  1348     self open
  1293 
  1349 
  1294     "Modified: 12.2.1997 / 11:58:21 / cg"
  1350     "Modified: 12.2.1997 / 11:58:21 / cg"
  1295 !
  1351 !
  1296 
  1352 
  1394 masterSlaveMessage:aSelector inGroup:aWindowGroup
  1450 masterSlaveMessage:aSelector inGroup:aWindowGroup
  1395     "send aSelector to partners and/or slaves.
  1451     "send aSelector to partners and/or slaves.
  1396      This is a private helper for destroy / mapped / unmapped"
  1452      This is a private helper for destroy / mapped / unmapped"
  1397 
  1453 
  1398     aWindowGroup notNil ifTrue:[
  1454     aWindowGroup notNil ifTrue:[
  1399 	"/
  1455         "/
  1400 	"/ if I am a master or partner, send to all slaves
  1456         "/ if I am a master or partner, send to all slaves
  1401 	"/
  1457         "/
  1402 	(self isMaster or:[self isPartner]) ifTrue:[
  1458         (self isMaster or:[self isPartner]) ifTrue:[
  1403 	    aWindowGroup slavesDo:[:v | v perform:aSelector].
  1459             aWindowGroup slavesDo:[:v | v perform:aSelector].
  1404 	].
  1460         ].
  1405 	"/
  1461         "/
  1406 	"/ if I am a partner, send to all partners
  1462         "/ if I am a partner, send to all partners
  1407 	"/
  1463         "/
  1408 	self isPartner ifTrue:[
  1464         self isPartner ifTrue:[
  1409 	    aWindowGroup partnersDo:[:v | v ~~ self ifTrue:[v perform:aSelector]].
  1465             aWindowGroup partnersDo:[:v | v ~~ self ifTrue:[v perform:aSelector]].
  1410 	].
  1466         ].
  1411     ].
  1467     ].
  1412 !
  1468 !
  1413 
  1469 
  1414 unmapped
  1470 unmapped
  1415     "the recevier was unmapped (i.e. iconified);
  1471     "the recevier was unmapped (i.e. iconified);
  1416      look for partners and slaves."
  1472      look for partners and slaves."
  1417 
  1473 
  1418     |r|
  1474     |r|
  1419 
  1475 
  1420     (windowGroup notNil and:[windowGroup isModal]) ifTrue:[
  1476     (windowGroup notNil and:[windowGroup isModal]) ifTrue:[
  1421 	"keep the realized flag true (to avoid exiting the modal event loop).
  1477         "keep the realized flag true (to avoid exiting the modal event loop).
  1422 	 Consider this a kludge."
  1478          Consider this a kludge."
  1423 	self markAsUnmappedModalBox.
  1479         self markAsUnmappedModalBox.
  1424 	r := realized.
  1480         r := realized.
  1425     ] ifFalse:[
  1481     ] ifFalse:[
  1426 	self unmarkAsUnmappedModalBox.
  1482         self unmarkAsUnmappedModalBox.
  1427 	r := realized := false.
  1483         r := realized := false.
  1428     ].
  1484     ].
  1429     super unmapped.
  1485     super unmapped.
  1430     realized := r.
  1486     realized := r.
  1431 
  1487 
  1432     "/
  1488     "/
  1438 ! !
  1494 ! !
  1439 
  1495 
  1440 !TopView class methodsFor:'documentation'!
  1496 !TopView class methodsFor:'documentation'!
  1441 
  1497 
  1442 version
  1498 version
  1443     ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.137 2011-03-03 18:17:42 cg Exp $'
  1499     ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.138 2011-03-03 18:22:14 cg Exp $'
  1444 !
  1500 !
  1445 
  1501 
  1446 version_CVS
  1502 version_CVS
  1447     ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.137 2011-03-03 18:17:42 cg Exp $'
  1503     ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.138 2011-03-03 18:22:14 cg Exp $'
  1448 ! !
  1504 ! !
  1449 
  1505 
  1450 TopView initialize!
  1506 TopView initialize!