PopUpView.st
author Claus Gittinger <cg@exept.de>
Wed, 31 Jan 1996 02:50:48 +0100
changeset 388 64e43f82d93e
parent 371 cc32d8f8bc8d
child 485 47c3cfae7ae2
permissions -rw-r--r--
Escape leaves modalBoxes or PopUpViews
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
6
7ee0cfde237d *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
48194c26a46c Initial revision
claus
parents:
diff changeset
    12
135
claus
parents: 89
diff changeset
    13
TopView subclass:#PopUpView
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    14
	 instanceVariableNames:'shadowView haveControl exclusivePointer'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    15
	 classVariableNames:'DefaultShadow DefaultLevel DefaultBorderWidth DefaultBorderColor'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    16
	 poolDictionaries:''
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    17
	 category:'Views-Basic'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    18
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    19
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    20
!PopUpView class methodsFor:'documentation'!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    21
46
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    22
copyright
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    23
"
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    25
	      All Rights Reserved
46
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    26
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    27
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    28
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    30
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    31
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    32
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    33
"
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    34
!
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    35
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    36
documentation
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    37
"
46
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    38
    this class implements an abstract superclass for all views which bypass the 
89
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
    39
    window manager and pop up on top of the screen. A typical example is
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
    40
    a PopUpMenu. PopUpView itself is abstract, providing basic mechanisms.
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
    41
    They are not decorated by window managers.
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    42
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
    43
    styleSheet parameters:
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    44
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
    45
	popupShadow         <Boolean>           if true, popupViews show a shadow below
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
    46
	popupLevel          <nil | Integer>     3D level
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
    47
	popupBorderWidth    <nil | Integer>     borderWidth
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    48
"
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    49
! !
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
    50
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    51
!PopUpView class methodsFor:'defaults'!
48194c26a46c Initial revision
claus
parents:
diff changeset
    52
48194c26a46c Initial revision
claus
parents:
diff changeset
    53
defaultExtent
135
claus
parents: 89
diff changeset
    54
    ^ (Display width // 3) @ (Display height // 3)
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
    55
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    56
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    57
shadows
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    58
    "return the shadows-flag. False means: turned off."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    59
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    60
    ^ DefaultShadow
144
claus
parents: 141
diff changeset
    61
!
claus
parents: 141
diff changeset
    62
claus
parents: 141
diff changeset
    63
shadows:aBoolean
claus
parents: 141
diff changeset
    64
    "turn on/off shadows under popUpViews. 
claus
parents: 141
diff changeset
    65
     On slow displays, turning them off makes menus appear a bit snappier.
claus
parents: 141
diff changeset
    66
     The default is set via the styleSheet and changes when the viewStyle
claus
parents: 141
diff changeset
    67
     is changed."
claus
parents: 141
diff changeset
    68
claus
parents: 141
diff changeset
    69
    DefaultShadow := aBoolean
claus
parents: 141
diff changeset
    70
!
claus
parents: 141
diff changeset
    71
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    72
updateStyleCache
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    73
    ShadowView isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    74
	DefaultShadow := false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    75
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    76
	DefaultShadow := StyleSheet at:'popupShadow' default:false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    77
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    78
    DefaultLevel := StyleSheet at:'popupLevel'.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    79
    DefaultBorderWidth := StyleSheet at:'popupBorderWidth'.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    80
    DefaultBorderColor := StyleSheet colorAt:'popupBorderColor'.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    81
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    82
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    83
!PopUpView methodsFor:'accessing'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    84
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    85
exclusivePointer:aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    86
    exclusivePointer := aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    87
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    88
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    89
noShadow
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    90
    "turn off the shadow"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    91
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    92
    shadowView := nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    93
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    94
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    95
!PopUpView methodsFor:'activation'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    96
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    97
hide
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    98
    "hide the view, leave its modal event loop"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    99
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   100
    windowGroup notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   101
	windowGroup removeView:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   102
	windowGroup := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   103
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   104
    self unrealize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   105
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   106
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   107
show
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   108
    "realize the view at its last position"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   109
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   110
    self fixSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   111
    self openModal:[true] "realize     "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   112
!
144
claus
parents: 141
diff changeset
   113
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   114
showAt:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   115
    "realize the view at aPoint"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   116
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   117
    self showAt:aPoint resizing:true 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   118
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   119
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   120
showAt:aPoint resizing:aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   121
    "realize the view at aPoint"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   122
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   123
    aBoolean ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   124
	self fixSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   125
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   126
    self origin:aPoint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   127
    self makeFullyVisible.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   128
    self openModal:[true] "realize     "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   129
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   130
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   131
showAtPointer
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   132
    "realize the view at the current pointer position"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   133
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   134
    self showAt:(device pointerPosition) resizing:true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   135
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   136
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   137
showCenteredIn:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   138
    "make myself visible at the screen center."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   139
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   140
    |top|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   141
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   142
    top := aView topView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   143
    top raise.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   144
    self showAt:(top origin 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   145
		 + (aView originRelativeTo:top) 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   146
		 + (aView extent // 2)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   147
		 - (self extent // 2))
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   148
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   149
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   150
!PopUpView methodsFor:'dispatching'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   151
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   152
modalLoop
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   153
    haveControl := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   154
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   155
    "this is a kludge - we do not have multiple processes, therefore
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   156
     we start another dispatch loop, which exits when control is lost"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   157
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   158
    device dispatchFor:nil while:[haveControl]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   159
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   160
89
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
   161
!PopUpView methodsFor:'initialize / release'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   162
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   163
create
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   164
    super create.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   165
    shadowView isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   166
	self saveUnder:true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   167
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   168
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   169
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   170
destroy
141
claus
parents: 135
diff changeset
   171
    haveControl := false.
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   172
    super destroy.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   173
    shadowView notNil ifTrue:[shadowView destroy. shadowView := nil]
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   174
!
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   175
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   176
initStyle
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   177
    super initStyle.
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   178
151
claus
parents: 144
diff changeset
   179
    styleSheet is3D == true ifTrue:[
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   180
	borderWidth := 0.
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   181
	level := 2
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   182
    ] ifFalse:[
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   183
	borderWidth := 1.
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   184
	level := 0
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   185
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   186
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   187
    DefaultBorderColor notNil ifTrue:[
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   188
	self borderColor:(DefaultBorderColor on:device).
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   189
    ].
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   190
    DefaultBorderWidth notNil ifTrue:[
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   191
	borderWidth := DefaultBorderWidth.
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   192
    ].
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   193
"/    DefaultEdgeStyle notNil ifTrue:[
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   194
"/        edgeStyle := DefaultEdgeStyle.
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   195
"/    ].
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   196
    DefaultLevel notNil ifTrue:[
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   197
	self level:DefaultLevel.
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   198
    ].
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   199
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   200
    DefaultShadow ifTrue:[
135
claus
parents: 89
diff changeset
   201
	shadowView := (ShadowView onDevice:device) for:self.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   202
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   203
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   204
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   205
initialize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   206
    super initialize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   207
    exclusivePointer := true.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   208
    haveControl := false.
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   209
    type := #popup 
162
claus
parents: 157
diff changeset
   210
!
claus
parents: 157
diff changeset
   211
claus
parents: 157
diff changeset
   212
releasePointer 
claus
parents: 157
diff changeset
   213
    device activePointerGrab == self ifTrue:[
claus
parents: 157
diff changeset
   214
	device ungrabPointer.
claus
parents: 157
diff changeset
   215
    ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   216
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   217
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   218
!PopUpView methodsFor:'private'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   219
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   220
leaveControl
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   221
    haveControl := false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   222
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   223
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   224
regainControl
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   225
    device grabPointerInView:self 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   226
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   227
48194c26a46c Initial revision
claus
parents:
diff changeset
   228
takeControl
48194c26a46c Initial revision
claus
parents:
diff changeset
   229
^ self.
48194c26a46c Initial revision
claus
parents:
diff changeset
   230
    haveControl := true.
48194c26a46c Initial revision
claus
parents:
diff changeset
   231
48194c26a46c Initial revision
claus
parents:
diff changeset
   232
    "this is a kludge - we do not have multiple processes, therefore
48194c26a46c Initial revision
claus
parents:
diff changeset
   233
     we start another dispatch loop, which exits when control is lost"
48194c26a46c Initial revision
claus
parents:
diff changeset
   234
48194c26a46c Initial revision
claus
parents:
diff changeset
   235
    device dispatchFor:drawableId while:[haveControl]
89
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
   236
! !
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
   237
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   238
!PopUpView methodsFor:'queries'!
89
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
   239
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   240
isPopUpView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   241
    ^ true
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   242
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   243
48194c26a46c Initial revision
claus
parents:
diff changeset
   244
!PopUpView methodsFor:'realize / unrealize'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   245
48194c26a46c Initial revision
claus
parents:
diff changeset
   246
mapped
162
claus
parents: 157
diff changeset
   247
    "grab the pointer here, when visible (but not control is already lost). 
claus
parents: 157
diff changeset
   248
     If the grab fails, try again and unrealize myself if that fails too."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   249
48194c26a46c Initial revision
claus
parents:
diff changeset
   250
    super mapped.
162
claus
parents: 157
diff changeset
   251
157
claus
parents: 151
diff changeset
   252
    (haveControl 
162
claus
parents: 157
diff changeset
   253
    and:[true "/ exclusivePointer
157
claus
parents: 151
diff changeset
   254
    and:[realized]]) ifTrue:[
141
claus
parents: 135
diff changeset
   255
	(device grabPointerInView:self) ifFalse:[
claus
parents: 135
diff changeset
   256
	    "wait a little bit and try again"
157
claus
parents: 151
diff changeset
   257
"/            'grab pointer failed' errorPrintNL.
371
cc32d8f8bc8d use new Delay-wait
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
   258
	    Delay waitForSeconds:0.1.
141
claus
parents: 135
diff changeset
   259
	    (device grabPointerInView:self) ifFalse:[
claus
parents: 135
diff changeset
   260
		"give up"
claus
parents: 135
diff changeset
   261
		'could not grab pointer' errorPrintNL.
claus
parents: 135
diff changeset
   262
		self unrealize
claus
parents: 135
diff changeset
   263
	    ]
162
claus
parents: 157
diff changeset
   264
	].
claus
parents: 157
diff changeset
   265
	exclusivePointer ifFalse:[
claus
parents: 157
diff changeset
   266
	    self releasePointer
claus
parents: 157
diff changeset
   267
	].
388
64e43f82d93e Escape leaves modalBoxes or PopUpViews
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   268
	self getKeyboardFocus
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   269
    ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   270
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   271
48194c26a46c Initial revision
claus
parents:
diff changeset
   272
realize
48194c26a46c Initial revision
claus
parents:
diff changeset
   273
    shadowView notNil ifTrue:[shadowView realize].
48194c26a46c Initial revision
claus
parents:
diff changeset
   274
    self raise.
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   275
    haveControl := true.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   276
    super realize.
48194c26a46c Initial revision
claus
parents:
diff changeset
   277
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   278
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   279
restarted
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   280
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   281
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   282
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   283
unrealize
48194c26a46c Initial revision
claus
parents:
diff changeset
   284
    haveControl := false.
81
4ba554473294 *** empty log message ***
claus
parents: 72
diff changeset
   285
    device activePointerGrab == self ifTrue:[
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   286
	device ungrabPointer.
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   287
    ].
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   288
    super unrealize.
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   289
    shadowView notNil ifTrue:[shadowView unrealize].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   290
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   291
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   292
!PopUpView class methodsFor:'documentation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   293
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   294
version
388
64e43f82d93e Escape leaves modalBoxes or PopUpViews
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   295
    ^ '$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.21 1996-01-31 01:50:42 cg Exp $'
157
claus
parents: 151
diff changeset
   296
! !