SimpleView.st
author Claus Gittinger <cg@exept.de>
Thu, 14 Dec 1995 18:39:48 +0100
changeset 312 a3500ca1f37b
parent 299 e2c8fd828a64
child 320 b7b8dc88fe9f
permissions -rw-r--r--
stefans changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
135
claus
parents:
diff changeset
     1
"
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
claus
parents:
diff changeset
     3
	      All Rights Reserved
claus
parents:
diff changeset
     4
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    10
 hereby transferred.
claus
parents:
diff changeset
    11
"
claus
parents:
diff changeset
    12
claus
parents:
diff changeset
    13
PseudoView subclass:#SimpleView
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    14
	 instanceVariableNames:'superView subViews components styleSheet resources borderColor
312
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    15
		borderWidth borderShape viewShape top left extentChanged
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    16
		originChanged cornerChanged relativeOrigin relativeExtent
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    17
		relativeCorner originRule extentRule cornerRule insets viewport
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    18
		layout shown hiddenOnRealize name level margin innerClipRect
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    19
		shadowColor lightColor bitGravity viewGravity controller
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    20
		windowGroup'
135
claus
parents:
diff changeset
    21
	 classVariableNames:'Grey CentPoint ViewSpacing DefaultStyle StyleSheet
312
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    22
		DefaultViewBackgroundColor DefaultBorderColor DefaultLightColor
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    23
		DefaultShadowColor DefaultBorderWidth DefaultFont
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    24
		DefaultFocusColor DefaultFocusBorderWidth'
135
claus
parents:
diff changeset
    25
	 poolDictionaries:''
claus
parents:
diff changeset
    26
	 category:'Views-Basic'
claus
parents:
diff changeset
    27
!
claus
parents:
diff changeset
    28
140
claus
parents: 138
diff changeset
    29
SimpleView class instanceVariableNames:'ClassResources'
claus
parents: 138
diff changeset
    30
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    31
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    32
 The following class instance variables are inherited by this class:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    33
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    34
	PseudoView - 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    35
	DeviceDrawable - 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    36
	DisplayMedium - 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    37
	GraphicsContext - 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    38
	Object - 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    39
"
140
claus
parents: 138
diff changeset
    40
!
135
claus
parents:
diff changeset
    41
claus
parents:
diff changeset
    42
!SimpleView class methodsFor:'documentation'!
claus
parents:
diff changeset
    43
claus
parents:
diff changeset
    44
copyright
claus
parents:
diff changeset
    45
"
claus
parents:
diff changeset
    46
 COPYRIGHT (c) 1989 by Claus Gittinger
claus
parents:
diff changeset
    47
	      All Rights Reserved
claus
parents:
diff changeset
    48
claus
parents:
diff changeset
    49
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    50
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    51
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    52
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    53
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    54
 hereby transferred.
claus
parents:
diff changeset
    55
"
claus
parents:
diff changeset
    56
!
claus
parents:
diff changeset
    57
claus
parents:
diff changeset
    58
documentation
claus
parents:
diff changeset
    59
"
claus
parents:
diff changeset
    60
    this class implements functions common to all Views which do not work on / show a model. 
claus
parents:
diff changeset
    61
    Previously, all of this functionality used to be in the old View class, but has been
claus
parents:
diff changeset
    62
    separated into this new SimpleView (which does not know about models) and the new View, which
claus
parents:
diff changeset
    63
    does so.
claus
parents:
diff changeset
    64
    Instances of SimpleView are seldom used, most views in the system inherit 
claus
parents:
diff changeset
    65
    from this class. 
claus
parents:
diff changeset
    66
    However, sometimes a view is used to create a dummy view for framing 
claus
parents:
diff changeset
    67
    or layout purposes.
claus
parents:
diff changeset
    68
claus
parents:
diff changeset
    69
    Instance variables:
claus
parents:
diff changeset
    70
claus
parents:
diff changeset
    71
	superView               <View>                  my superview i.e. the view I am in
claus
parents:
diff changeset
    72
	subViews                <Collection>            the collection of subviews
151
claus
parents: 145
diff changeset
    73
	components              <Collection>            collection of gadgets (will be merged with subViews, soon)
claus
parents: 145
diff changeset
    74
135
claus
parents:
diff changeset
    75
	borderColor             <Color>                 color of border
claus
parents:
diff changeset
    76
	borderWidth             <Number>                borderWidth in pixels (device dep.)
claus
parents:
diff changeset
    77
	borderShape             <Form>                  shape of border (if device supports it)
claus
parents:
diff changeset
    78
	viewShape               <Form>                  shape of view (if device supports it)
151
claus
parents: 145
diff changeset
    79
	top                     <Number>                actual top coordinate (pixels) in superview
claus
parents: 145
diff changeset
    80
	left                    <Number>                actual left coordinate (pixels) in superview
135
claus
parents:
diff changeset
    81
	extendChanged           <Boolean>               true if extend changed during setup
claus
parents:
diff changeset
    82
	originChanged           <Boolean>               true if origin changed during setup
151
claus
parents: 145
diff changeset
    83
claus
parents: 145
diff changeset
    84
	viewport                <Rectangle>             my Rectangle in superviews coordinates
135
claus
parents:
diff changeset
    85
	relativeOrigin          <Number>                relative origin in percent within superview
claus
parents:
diff changeset
    86
	relativeExtent          <Number>                relative extent in percent within superview
151
claus
parents: 145
diff changeset
    87
	relativeCorner          <Number>                relative corner in percent within superview
135
claus
parents:
diff changeset
    88
	originRule              <Block>                 rule to compute origin if superview changes size
claus
parents:
diff changeset
    89
	extentRule              <Block>                 rule to compute extent if superview changes size
151
claus
parents: 145
diff changeset
    90
	cornerRule              <Block>                 rule to compute corner if superview changes size
claus
parents: 145
diff changeset
    91
	insets                  <Array>                 array with top, left, bottom & right insets (or nil)
claus
parents: 145
diff changeset
    92
claus
parents: 145
diff changeset
    93
	layout                  <LayoutObject>          not yet implemented - will replace the above layout
claus
parents: 145
diff changeset
    94
							variables.
claus
parents: 145
diff changeset
    95
135
claus
parents:
diff changeset
    96
	shown                   <Boolean>               true if visible (false if iconified, unmapped or covered)
151
claus
parents: 145
diff changeset
    97
	hiddenOnRealize         <Boolean>               dont show automatically when superview is realized
135
claus
parents:
diff changeset
    98
	name                    <String>                my name (future use for resources)
claus
parents:
diff changeset
    99
	level                   <Number>                3D level relative to superview
claus
parents:
diff changeset
   100
	margin                  <Number>                convenient margin
claus
parents:
diff changeset
   101
	innerClipRect           <Rectangle>             convenient inner clip (minus margin)
claus
parents:
diff changeset
   102
	shadowColor             <Color>                 color used to draw 3D shadowed edges
claus
parents:
diff changeset
   103
	lightColor              <Color>                 color used to draw 3D lighted edges
claus
parents:
diff changeset
   104
	bitGravity              <nil | Symbol>          gravity of contents (if device supports it)
claus
parents:
diff changeset
   105
	viewGravity             <nil | Symbol>          gravity of view (if device supports it)
claus
parents:
diff changeset
   106
	controller              <nil | Controller>      the controller (if any)
151
claus
parents: 145
diff changeset
   107
	windowGroup             <WindowGroup>           the windowGroup
135
claus
parents:
diff changeset
   108
claus
parents:
diff changeset
   109
claus
parents:
diff changeset
   110
    Class variables:
claus
parents:
diff changeset
   111
claus
parents:
diff changeset
   112
	Grey                    <Color>                 the color grey - its used so often
151
claus
parents: 145
diff changeset
   113
	ViewSpacing             <Number>                preferred spacing between views; 1mm
135
claus
parents:
diff changeset
   114
claus
parents:
diff changeset
   115
	CentPoint               <Point>                 100 @ 100 - its used so often
claus
parents:
diff changeset
   116
claus
parents:
diff changeset
   117
	StyleSheet              <ResourcePack>          contains all view-style specifics
claus
parents:
diff changeset
   118
claus
parents:
diff changeset
   119
claus
parents:
diff changeset
   120
    styleSheet parameters:
claus
parents:
diff changeset
   121
claus
parents:
diff changeset
   122
	popupShadow             <Boolean>               if true, popupViews show a shadow below
claus
parents:
diff changeset
   123
	popupLevel              <nil | Integer>         3D level
claus
parents:
diff changeset
   124
	borderWidth             <nil | Integer>         borderWidth (ignored in 3D styles)
claus
parents:
diff changeset
   125
	borderColor             <nil | Color>           borderColor (ignored in 3D styles)
claus
parents:
diff changeset
   126
	viewBackground          <nil | Color>           views background
claus
parents:
diff changeset
   127
	shadowColor             <nil | Color>           color for shadow edges (ignored in 2D styles)
claus
parents:
diff changeset
   128
	lightColor              <nil | Color>           color for light edges (ignored in 2D styles)
claus
parents:
diff changeset
   129
	font                    <nil | Font>            font to use
claus
parents:
diff changeset
   130
claus
parents:
diff changeset
   131
claus
parents:
diff changeset
   132
    TODO:
claus
parents:
diff changeset
   133
	get rid of relativeOrigin, relativeCorner, originRule, extentRule,
claus
parents:
diff changeset
   134
	and insets; replace by a single object which defines the size
claus
parents:
diff changeset
   135
	(mhmh - ST-80 seems to call this LayoutFrame ?)
claus
parents:
diff changeset
   136
	-> be prepared for a change here in the near future and ONLY use
151
claus
parents: 145
diff changeset
   137
	   access methods to get those instance variables' values
claus
parents: 145
diff changeset
   138
claus
parents: 145
diff changeset
   139
	get rid of 3D level & margin, move it to extra wrappers
claus
parents: 145
diff changeset
   140
	(although this will make view setup more complicated, it will remove
claus
parents: 145
diff changeset
   141
	 complexity from the internals of view. Also, it will allow for more
claus
parents: 145
diff changeset
   142
	 varieties of borders.)
claus
parents: 145
diff changeset
   143
        
135
claus
parents:
diff changeset
   144
	add components (could also call them gadgets or lightweight views)
claus
parents:
diff changeset
   145
	- views are expensive in terms of X resources. This would make all
claus
parents:
diff changeset
   146
	framing/edge and panel helper views become cheap ST objects, instead
claus
parents:
diff changeset
   147
	of views.
claus
parents:
diff changeset
   148
"
151
claus
parents: 145
diff changeset
   149
!
claus
parents: 145
diff changeset
   150
claus
parents: 145
diff changeset
   151
examples 
claus
parents: 145
diff changeset
   152
"
claus
parents: 145
diff changeset
   153
    (all examples below use different viewBackgrounds, 
claus
parents: 145
diff changeset
   154
     to make the individual subviews visible)
claus
parents: 145
diff changeset
   155
claus
parents: 145
diff changeset
   156
    fixed position/size:
claus
parents: 145
diff changeset
   157
claus
parents: 145
diff changeset
   158
       |top v1 v2|
claus
parents: 145
diff changeset
   159
claus
parents: 145
diff changeset
   160
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   161
       top extent:300@300.
claus
parents: 145
diff changeset
   162
claus
parents: 145
diff changeset
   163
       v1 := View origin:10@10
claus
parents: 145
diff changeset
   164
		  corner:50@50
claus
parents: 145
diff changeset
   165
		      in:top.
claus
parents: 145
diff changeset
   166
       v2 := View origin:60@10
claus
parents: 145
diff changeset
   167
		  corner:150@100
claus
parents: 145
diff changeset
   168
		      in:top.
claus
parents: 145
diff changeset
   169
claus
parents: 145
diff changeset
   170
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   171
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   172
claus
parents: 145
diff changeset
   173
       top open
claus
parents: 145
diff changeset
   174
claus
parents: 145
diff changeset
   175
claus
parents: 145
diff changeset
   176
    same, using ST-80 way of bulding up view hierarchies
claus
parents: 145
diff changeset
   177
    (recommended, if you plan to port applications later)
claus
parents: 145
diff changeset
   178
claus
parents: 145
diff changeset
   179
       |top v1 v2|
claus
parents: 145
diff changeset
   180
claus
parents: 145
diff changeset
   181
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   182
       top extent:300@300.
claus
parents: 145
diff changeset
   183
claus
parents: 145
diff changeset
   184
       v1 := View new.
claus
parents: 145
diff changeset
   185
       v1 origin:10@10 corner:50@50.
claus
parents: 145
diff changeset
   186
claus
parents: 145
diff changeset
   187
       v2 := View new.
claus
parents: 145
diff changeset
   188
       v2 origin:60@10 corner:150@100.
claus
parents: 145
diff changeset
   189
claus
parents: 145
diff changeset
   190
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   191
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   192
claus
parents: 145
diff changeset
   193
       top add:v1.
claus
parents: 145
diff changeset
   194
       top add:v2.
claus
parents: 145
diff changeset
   195
claus
parents: 145
diff changeset
   196
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   197
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   198
claus
parents: 145
diff changeset
   199
       top open
claus
parents: 145
diff changeset
   200
claus
parents: 145
diff changeset
   201
claus
parents: 145
diff changeset
   202
    fixed origin, variable size:
claus
parents: 145
diff changeset
   203
claus
parents: 145
diff changeset
   204
       |top v1 v2|
claus
parents: 145
diff changeset
   205
claus
parents: 145
diff changeset
   206
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   207
       top extent:300@300.
claus
parents: 145
diff changeset
   208
claus
parents: 145
diff changeset
   209
       v1 := View new.
claus
parents: 145
diff changeset
   210
       v1 origin:10@10 corner:50@0.5.
claus
parents: 145
diff changeset
   211
claus
parents: 145
diff changeset
   212
       v2 := View new.
claus
parents: 145
diff changeset
   213
       v2 origin:60@10 corner:150@0.5.
claus
parents: 145
diff changeset
   214
claus
parents: 145
diff changeset
   215
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   216
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   217
claus
parents: 145
diff changeset
   218
       top add:v1.
claus
parents: 145
diff changeset
   219
       top add:v2.
claus
parents: 145
diff changeset
   220
claus
parents: 145
diff changeset
   221
       top open
claus
parents: 145
diff changeset
   222
claus
parents: 145
diff changeset
   223
claus
parents: 145
diff changeset
   224
    fixed origin, variable size, 
claus
parents: 145
diff changeset
   225
    bottomInset for constant distance from bottom:
claus
parents: 145
diff changeset
   226
claus
parents: 145
diff changeset
   227
       |top v1 v2|
claus
parents: 145
diff changeset
   228
claus
parents: 145
diff changeset
   229
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   230
       top extent:300@300.
claus
parents: 145
diff changeset
   231
claus
parents: 145
diff changeset
   232
       v1 := View new.
claus
parents: 145
diff changeset
   233
       v1 origin:10@10 corner:50@1.0.
claus
parents: 145
diff changeset
   234
       v1 bottomInset:10.
claus
parents: 145
diff changeset
   235
claus
parents: 145
diff changeset
   236
       v2 := View new.
claus
parents: 145
diff changeset
   237
       v2 origin:60@10 corner:150@1.0.
claus
parents: 145
diff changeset
   238
       v2 bottomInset:10.
claus
parents: 145
diff changeset
   239
claus
parents: 145
diff changeset
   240
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   241
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   242
claus
parents: 145
diff changeset
   243
       top add:v1.
claus
parents: 145
diff changeset
   244
       top add:v2.
claus
parents: 145
diff changeset
   245
claus
parents: 145
diff changeset
   246
       top open
claus
parents: 145
diff changeset
   247
claus
parents: 145
diff changeset
   248
claus
parents: 145
diff changeset
   249
    variable origin, variable size, 
claus
parents: 145
diff changeset
   250
claus
parents: 145
diff changeset
   251
       |top v1 v2|
claus
parents: 145
diff changeset
   252
claus
parents: 145
diff changeset
   253
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   254
       top extent:300@300.
claus
parents: 145
diff changeset
   255
claus
parents: 145
diff changeset
   256
       v1 := View new.
claus
parents: 145
diff changeset
   257
       v1 origin:0.0@0.0 corner:0.5@0.5.
claus
parents: 145
diff changeset
   258
claus
parents: 145
diff changeset
   259
       v2 := View new.
claus
parents: 145
diff changeset
   260
       v2 origin:0.5@0.0 corner:1.0@0.5.
claus
parents: 145
diff changeset
   261
claus
parents: 145
diff changeset
   262
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   263
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   264
claus
parents: 145
diff changeset
   265
       top add:v1.
claus
parents: 145
diff changeset
   266
       top add:v2.
claus
parents: 145
diff changeset
   267
claus
parents: 145
diff changeset
   268
       top open
claus
parents: 145
diff changeset
   269
claus
parents: 145
diff changeset
   270
claus
parents: 145
diff changeset
   271
    variable origin, variable size, 
claus
parents: 145
diff changeset
   272
    insets for some constant distance
claus
parents: 145
diff changeset
   273
claus
parents: 145
diff changeset
   274
       |top v1 v2|
claus
parents: 145
diff changeset
   275
claus
parents: 145
diff changeset
   276
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   277
       top extent:300@300.
claus
parents: 145
diff changeset
   278
claus
parents: 145
diff changeset
   279
       v1 := View new.
claus
parents: 145
diff changeset
   280
       v1 origin:0.0@0.0 corner:0.5@0.5.
claus
parents: 145
diff changeset
   281
       v1 rightInset:5.
claus
parents: 145
diff changeset
   282
claus
parents: 145
diff changeset
   283
       v2 := View new.
claus
parents: 145
diff changeset
   284
       v2 origin:0.5@0.0 corner:1.0@0.5.
claus
parents: 145
diff changeset
   285
       v2 leftInset:5.
claus
parents: 145
diff changeset
   286
claus
parents: 145
diff changeset
   287
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   288
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   289
claus
parents: 145
diff changeset
   290
       top add:v1.
claus
parents: 145
diff changeset
   291
       top add:v2.
claus
parents: 145
diff changeset
   292
claus
parents: 145
diff changeset
   293
       top open
claus
parents: 145
diff changeset
   294
claus
parents: 145
diff changeset
   295
claus
parents: 145
diff changeset
   296
    using layout objects (ST-80 style):
claus
parents: 145
diff changeset
   297
    fully specifying the frame
claus
parents: 145
diff changeset
   298
claus
parents: 145
diff changeset
   299
       |top v1 v2|
claus
parents: 145
diff changeset
   300
claus
parents: 145
diff changeset
   301
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   302
       top extent:300@300.
claus
parents: 145
diff changeset
   303
claus
parents: 145
diff changeset
   304
       v1 := View new.
claus
parents: 145
diff changeset
   305
       v2 := View new.
claus
parents: 145
diff changeset
   306
claus
parents: 145
diff changeset
   307
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   308
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   309
claus
parents: 145
diff changeset
   310
       top add:v1 in:(LayoutFrame new
claus
parents: 145
diff changeset
   311
			leftFraction:0.25;
claus
parents: 145
diff changeset
   312
			rightFraction:0.75;
claus
parents: 145
diff changeset
   313
			topFraction:0.0;
claus
parents: 145
diff changeset
   314
			bottomFraction:0.5).
claus
parents: 145
diff changeset
   315
       top add:v2 in:(LayoutFrame new
claus
parents: 145
diff changeset
   316
			leftFraction:0.5;
claus
parents: 145
diff changeset
   317
			rightFraction:1.0;
claus
parents: 145
diff changeset
   318
			topFraction:0.5;
claus
parents: 145
diff changeset
   319
			bottomFraction:0.75).
claus
parents: 145
diff changeset
   320
claus
parents: 145
diff changeset
   321
       top open
claus
parents: 145
diff changeset
   322
claus
parents: 145
diff changeset
   323
claus
parents: 145
diff changeset
   324
    another one, with offsets:
claus
parents: 145
diff changeset
   325
claus
parents: 145
diff changeset
   326
       |top v1 v2|
claus
parents: 145
diff changeset
   327
claus
parents: 145
diff changeset
   328
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   329
       top extent:300@300.
claus
parents: 145
diff changeset
   330
claus
parents: 145
diff changeset
   331
       v1 := View new.
claus
parents: 145
diff changeset
   332
       v2 := View new.
claus
parents: 145
diff changeset
   333
claus
parents: 145
diff changeset
   334
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   335
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   336
claus
parents: 145
diff changeset
   337
       top add:v1 in:(LayoutFrame new
claus
parents: 145
diff changeset
   338
			leftFraction:0.0 offset:10;
claus
parents: 145
diff changeset
   339
			rightFraction:1.0 offset:-10;
claus
parents: 145
diff changeset
   340
			topFraction:0.0 offset:10;
claus
parents: 145
diff changeset
   341
			bottomFraction:0.5).
claus
parents: 145
diff changeset
   342
       top add:v2 in:(LayoutFrame new
claus
parents: 145
diff changeset
   343
			leftFraction:0.0 offset:30;
claus
parents: 145
diff changeset
   344
			rightFraction:1.0 offset:-30;
claus
parents: 145
diff changeset
   345
			topFraction:0.5 offset:10;
claus
parents: 145
diff changeset
   346
			bottomFraction:0.75).
claus
parents: 145
diff changeset
   347
claus
parents: 145
diff changeset
   348
       top open
claus
parents: 145
diff changeset
   349
claus
parents: 145
diff changeset
   350
claus
parents: 145
diff changeset
   351
    specifying origin only. Extent is views preferred
claus
parents: 145
diff changeset
   352
    (notice, that plain views have some defaultExtent of 100@100)
claus
parents: 145
diff changeset
   353
claus
parents: 145
diff changeset
   354
       |top v1 v2|
claus
parents: 145
diff changeset
   355
claus
parents: 145
diff changeset
   356
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   357
       top extent:300@300.
claus
parents: 145
diff changeset
   358
claus
parents: 145
diff changeset
   359
       v1 := View new.
claus
parents: 145
diff changeset
   360
       v2 := View new.
claus
parents: 145
diff changeset
   361
claus
parents: 145
diff changeset
   362
       v1 viewBackground:(Color red).
claus
parents: 145
diff changeset
   363
       v2 viewBackground:(Color yellow).
claus
parents: 145
diff changeset
   364
claus
parents: 145
diff changeset
   365
       top add:v1 in:(LayoutOrigin new
claus
parents: 145
diff changeset
   366
			leftFraction:0.25;
claus
parents: 145
diff changeset
   367
			topFraction:0.0).
claus
parents: 145
diff changeset
   368
       top add:v2 in:(LayoutOrigin new
claus
parents: 145
diff changeset
   369
			leftFraction:0.5;
claus
parents: 145
diff changeset
   370
			topFraction:0.5).
claus
parents: 145
diff changeset
   371
claus
parents: 145
diff changeset
   372
       top open
claus
parents: 145
diff changeset
   373
claus
parents: 145
diff changeset
   374
    same example, using buttons which compute their preferredBounds:
claus
parents: 145
diff changeset
   375
claus
parents: 145
diff changeset
   376
       |top v1 v2|
claus
parents: 145
diff changeset
   377
claus
parents: 145
diff changeset
   378
       top := StandardSystemView new.
claus
parents: 145
diff changeset
   379
       top extent:300@300.
claus
parents: 145
diff changeset
   380
claus
parents: 145
diff changeset
   381
       v1 := Button label:'foo'.
claus
parents: 145
diff changeset
   382
       v2 := Button label:'a very long buttonLabel'.
claus
parents: 145
diff changeset
   383
claus
parents: 145
diff changeset
   384
       v1 backgroundColor:(Color red).
claus
parents: 145
diff changeset
   385
       v2 backgroundColor:(Color yellow).
claus
parents: 145
diff changeset
   386
claus
parents: 145
diff changeset
   387
       top add:v1 in:(LayoutOrigin new
claus
parents: 145
diff changeset
   388
			leftFraction:0.25;
claus
parents: 145
diff changeset
   389
			topFraction:0.0).
claus
parents: 145
diff changeset
   390
       top add:v2 in:(LayoutOrigin new
claus
parents: 145
diff changeset
   391
			leftFraction:0.5;
claus
parents: 145
diff changeset
   392
			topFraction:0.5).
claus
parents: 145
diff changeset
   393
claus
parents: 145
diff changeset
   394
       top open
claus
parents: 145
diff changeset
   395
claus
parents: 145
diff changeset
   396
"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   397
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   398
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   399
layoutComputation 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   400
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   401
    Due to historic reasons, there are 2 mechanisms to resize a view:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   402
	- (old, to be eliminated mechanism)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   403
	    based upon info found in 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   404
		relativeOrigin / relativeCorner / relativeExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   405
		originRule / cornerRule / extentRule
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   406
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   407
	- (new, will migrate to that one)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   408
	    letting a layoutObject compute things
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   409
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   410
    Actually, the old mechanism is just as powerful, as the new (layoutObject
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   411
    based) mechanism; with the help of block=rules, you can compute whatever
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   412
    geometry is desired.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   413
    However, having 6 instance variables in every view creates some overhead,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   414
    which can be avoided in most cases (most views are either fixed-size or
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   415
    relative-sized).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   416
    Therefore (and also to make porting of ST-80 apps easier), ST/X will migrate 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   417
    to use layoutObjects.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   418
    You will not see a difference at the views protocol level, since
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   419
    existing interfaces will (silently) create layoutObjects as appropriate.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   420
    However, you should remove all direct accesses to the above mentioned
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   421
    instance variables, to be prepared for that change.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   422
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   423
    Notice, that a view recomputes its size whenever its superview
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   424
    changes size. This is done via:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   425
	sizeChanged
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   426
	    -> allSubviews: superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   427
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   428
    If the geometry computation as performed in superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   429
    is not powerful enough for your application, you can either:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   430
	- redefine superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   431
	- create a special layoutObject which computes a new layout.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   432
"
135
claus
parents:
diff changeset
   433
! !
claus
parents:
diff changeset
   434
claus
parents:
diff changeset
   435
!SimpleView class methodsFor:'initialization'!
claus
parents:
diff changeset
   436
claus
parents:
diff changeset
   437
initialize
claus
parents:
diff changeset
   438
    DefaultStyle isNil ifTrue:[
claus
parents:
diff changeset
   439
	Font initialize.
claus
parents:
diff changeset
   440
	Form initialize.
claus
parents:
diff changeset
   441
	Color initialize.
claus
parents:
diff changeset
   442
claus
parents:
diff changeset
   443
	Display notNil ifTrue:[
claus
parents:
diff changeset
   444
	    self defaultStyle:#normal.
claus
parents:
diff changeset
   445
	].
claus
parents:
diff changeset
   446
claus
parents:
diff changeset
   447
"/    self updateStyleCache.
claus
parents:
diff changeset
   448
	self == SimpleView ifTrue:[
claus
parents:
diff changeset
   449
	    Smalltalk addDependent:self   "/ to get language changes
claus
parents:
diff changeset
   450
	]
claus
parents:
diff changeset
   451
    ]
claus
parents:
diff changeset
   452
!
claus
parents:
diff changeset
   453
claus
parents:
diff changeset
   454
postAutoload
claus
parents:
diff changeset
   455
    self updateStyleCache.
claus
parents:
diff changeset
   456
! !
claus
parents:
diff changeset
   457
claus
parents:
diff changeset
   458
!SimpleView class methodsFor:'instance creation'!
claus
parents:
diff changeset
   459
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   460
extent:extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   461
    "create a new view with given extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   462
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   463
    ^ self origin:nil extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   464
		      font:nil label:nil in:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   465
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   466
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   467
extent:extent in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   468
    "create a new view as a subview of aView with given extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   469
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   470
    ^ self origin:nil extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   471
		      font:nil label:nil in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   472
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   473
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   474
extent:extent label:label
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   475
    "create a new view with given extent and label"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   476
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   477
    ^ self origin:nil extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   478
		      font:nil label:label in:nil
135
claus
parents:
diff changeset
   479
!
claus
parents:
diff changeset
   480
claus
parents:
diff changeset
   481
in:aView
claus
parents:
diff changeset
   482
    "return a new view as a subview of aView.
claus
parents:
diff changeset
   483
     If aView is nil, it is left unspecified, in which superview
claus
parents:
diff changeset
   484
     the new view will be placed. The view can later be assigned
claus
parents:
diff changeset
   485
     by adding it to the superview via #addSubView:.
claus
parents:
diff changeset
   486
     If realized and no superview has ever been set, it will come
claus
parents:
diff changeset
   487
     up as a topview."
claus
parents:
diff changeset
   488
claus
parents:
diff changeset
   489
    |newView|
claus
parents:
diff changeset
   490
claus
parents:
diff changeset
   491
    newView := self basicNew.
claus
parents:
diff changeset
   492
    aView notNil ifTrue:[
claus
parents:
diff changeset
   493
	newView device:(aView device).
claus
parents:
diff changeset
   494
	newView superView:aView.
claus
parents:
diff changeset
   495
    ] ifFalse:[
151
claus
parents: 145
diff changeset
   496
	newView device:Screen current "Display"
135
claus
parents:
diff changeset
   497
    ].
claus
parents:
diff changeset
   498
    newView initialize.
claus
parents:
diff changeset
   499
    aView notNil ifTrue:[aView addSubView:newView].
claus
parents:
diff changeset
   500
    ^ newView
claus
parents:
diff changeset
   501
!
claus
parents:
diff changeset
   502
140
claus
parents: 138
diff changeset
   503
label:label
claus
parents: 138
diff changeset
   504
    "create a new view with given label"
135
claus
parents:
diff changeset
   505
claus
parents:
diff changeset
   506
    ^ self origin:nil extent:nil borderWidth:nil
140
claus
parents: 138
diff changeset
   507
		      font:nil label:label in:nil
claus
parents: 138
diff changeset
   508
!
claus
parents: 138
diff changeset
   509
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   510
label:label in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   511
    "create a new view as subview of aView with given label"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   512
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   513
    ^ self origin:nil extent:nil borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   514
		      font:nil label:label in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   515
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   516
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   517
on:aModel
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   518
    "create a new drawable on aModel"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   519
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   520
    "although this one does not know about models,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   521
     it can still send the model-assign message. This was done
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   522
     to catch obsolete calls to on:aDevice.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   523
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   524
    ^ self new model:aModel.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   525
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   526
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   527
onSameDeviceAs:anotherView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   528
    "create a view on the same device as anotherView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   529
     Used with popUpMenus, which should be created on the device of
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   530
     its masterView."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   531
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   532
    |device|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   533
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   534
    anotherView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   535
	device := anotherView device.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   536
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   537
	device := Screen current "Display".
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   538
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   539
    ^ self onDevice:device
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   540
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   541
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   542
origin:origin corner:corner 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   543
    "create a new view with given origin and extent"
135
claus
parents:
diff changeset
   544
140
claus
parents: 138
diff changeset
   545
    ^ self origin:origin corner:corner borderWidth:nil
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   546
			 font:nil label:nil in:nil
135
claus
parents:
diff changeset
   547
!
claus
parents:
diff changeset
   548
claus
parents:
diff changeset
   549
origin:anOrigin corner:aCorner borderWidth:bw font:aFont label:aLabel in:aView
claus
parents:
diff changeset
   550
    |newView|
claus
parents:
diff changeset
   551
claus
parents:
diff changeset
   552
    aView notNil ifTrue:[
claus
parents:
diff changeset
   553
	newView := self basicNew.
claus
parents:
diff changeset
   554
	newView device:(aView device).
claus
parents:
diff changeset
   555
	aView addSubView:newView.
claus
parents:
diff changeset
   556
	newView initialize
claus
parents:
diff changeset
   557
    ] ifFalse:[
151
claus
parents: 145
diff changeset
   558
	newView := self onDevice:Screen current "Display"
135
claus
parents:
diff changeset
   559
    ].
claus
parents:
diff changeset
   560
    bw notNil ifTrue:[newView borderWidth:bw].
claus
parents:
diff changeset
   561
    anOrigin notNil ifTrue:[newView origin:anOrigin].
claus
parents:
diff changeset
   562
    aCorner notNil ifTrue:[newView corner:aCorner].
claus
parents:
diff changeset
   563
    aFont notNil ifTrue:[newView font:aFont].
claus
parents:
diff changeset
   564
    aLabel notNil ifTrue:[newView label:aLabel].
claus
parents:
diff changeset
   565
    ^ newView
claus
parents:
diff changeset
   566
!
claus
parents:
diff changeset
   567
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   568
origin:origin corner:corner borderWidth:bw in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   569
    "create a new view as a subview of aView with given origin and extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   570
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   571
    ^ self origin:origin corner:corner borderWidth:bw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   572
			 font:nil label:nil in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   573
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   574
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   575
origin:origin corner:corner in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   576
    "create a new view as a subview of aView with given origin and extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   577
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   578
    ^ self origin:origin corner:corner borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   579
			 font:nil label:nil in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   580
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   581
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   582
origin:origin extent:extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   583
    "create a new view with given origin and extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   584
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   585
    ^ self origin:origin extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   586
			 font:nil label:nil in:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   587
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   588
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   589
origin:origin extent:extent borderWidth:bw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   590
    "create a new view with given origin, extent and borderWidth"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   591
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   592
    ^ self origin:origin extent:extent borderWidth:bw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   593
			 font:nil label:nil in:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   594
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   595
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   596
origin:anOrigin extent:anExtent borderWidth:bw font:aFont label:aLabel in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   597
    |newView|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   598
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   599
    aView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   600
	newView := self basicNew.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   601
	newView device:(aView device).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   602
	aView addSubView:newView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   603
	newView initialize
140
claus
parents: 138
diff changeset
   604
    ] ifFalse:[
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   605
	newView := self onDevice:Screen current "Display"
140
claus
parents: 138
diff changeset
   606
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   607
    bw notNil ifTrue:[newView borderWidth:bw].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   608
    anExtent notNil ifTrue:[newView extent:anExtent].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   609
    anOrigin notNil ifTrue:[newView origin:anOrigin].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   610
    aFont notNil ifTrue:[newView font:aFont].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   611
    aLabel notNil ifTrue:[newView label:aLabel].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   612
    ^ newView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   613
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   614
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   615
origin:origin extent:extent borderWidth:bw in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   616
    "create a new view as a subview of aView with given origin, extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   617
     and borderWidth"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   618
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   619
    ^ self origin:origin extent:extent borderWidth:bw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   620
			 font:nil label:nil in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   621
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   622
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   623
origin:origin extent:extent font:aFont label:label
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   624
    ^ self origin:origin extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   625
			 font:nil label:label in:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   626
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   627
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   628
origin:origin extent:extent font:aFont label:label in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   629
    ^ self origin:origin extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   630
			 font:aFont label:label in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   631
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   632
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   633
origin:origin extent:extent in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   634
    "create a new view as a subview of aView with given origin and extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   635
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   636
    ^ self origin:origin extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   637
			 font:nil label:nil in:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   638
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   639
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   640
origin:origin extent:extent label:label
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   641
    "create a new view with given origin, extent and label"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   642
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   643
    ^ self origin:origin extent:extent borderWidth:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   644
			 font:nil label:label in:nil
135
claus
parents:
diff changeset
   645
!
claus
parents:
diff changeset
   646
claus
parents:
diff changeset
   647
origin:anOrigin extent:anExtent
claus
parents:
diff changeset
   648
		label:aLabel icon:aForm
claus
parents:
diff changeset
   649
		minExtent:minExtent maxExtent:maxExtent
claus
parents:
diff changeset
   650
    |newView|
claus
parents:
diff changeset
   651
151
claus
parents: 145
diff changeset
   652
    newView := self onDevice:Screen current "Display".
135
claus
parents:
diff changeset
   653
    anOrigin notNil ifTrue:[newView origin:anOrigin].
claus
parents:
diff changeset
   654
    anExtent notNil ifTrue:[newView extent:anExtent].
claus
parents:
diff changeset
   655
    aLabel notNil ifTrue:[newView label:aLabel].
claus
parents:
diff changeset
   656
    aForm notNil ifTrue:[newView icon:aForm].
claus
parents:
diff changeset
   657
    minExtent notNil ifTrue:[newView minExtent:minExtent].
claus
parents:
diff changeset
   658
    maxExtent notNil ifTrue:[newView maxExtent:maxExtent].
claus
parents:
diff changeset
   659
    ^ newView
claus
parents:
diff changeset
   660
!
claus
parents:
diff changeset
   661
140
claus
parents: 138
diff changeset
   662
origin:origin in:aView
claus
parents: 138
diff changeset
   663
    "create a new view as a subview of aView with given origin"
claus
parents: 138
diff changeset
   664
claus
parents: 138
diff changeset
   665
    ^ self origin:origin extent:nil borderWidth:nil
claus
parents: 138
diff changeset
   666
			 font:nil label:nil in:aView
135
claus
parents:
diff changeset
   667
! !
claus
parents:
diff changeset
   668
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   669
!SimpleView class methodsFor:'change & update'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   670
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   671
update:something
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   672
    something == #Language ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   673
	"flush resources on language changes"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   674
	self flushAllClassResources
135
claus
parents:
diff changeset
   675
    ]
claus
parents:
diff changeset
   676
! !
claus
parents:
diff changeset
   677
claus
parents:
diff changeset
   678
!SimpleView class methodsFor:'defaults'!
claus
parents:
diff changeset
   679
140
claus
parents: 138
diff changeset
   680
defaultExtent
claus
parents: 138
diff changeset
   681
    "define the default extent"
claus
parents: 138
diff changeset
   682
claus
parents: 138
diff changeset
   683
    CentPoint isNil ifTrue:[CentPoint := 100 @ 100].
claus
parents: 138
diff changeset
   684
    ^ CentPoint
claus
parents: 138
diff changeset
   685
!
claus
parents: 138
diff changeset
   686
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   687
defaultFont
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   688
    ^ DefaultFont notNil ifTrue:[DefaultFont] ifFalse:[super defaultFont]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   689
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   690
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   691
defaultStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   692
    "return the default view style"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   693
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   694
    ^ DefaultStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   695
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   696
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   697
     View defaultStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   698
    "
135
claus
parents:
diff changeset
   699
!
claus
parents:
diff changeset
   700
claus
parents:
diff changeset
   701
defaultStyle:aStyle
claus
parents:
diff changeset
   702
    "set the view style for new views"
claus
parents:
diff changeset
   703
180
claus
parents: 176
diff changeset
   704
"/    aStyle ~~ DefaultStyle ifTrue:[
135
claus
parents:
diff changeset
   705
	DefaultStyle := aStyle.
claus
parents:
diff changeset
   706
	self updateAllStyleCaches.
180
claus
parents: 176
diff changeset
   707
"/    ]
135
claus
parents:
diff changeset
   708
claus
parents:
diff changeset
   709
    "
claus
parents:
diff changeset
   710
     View defaultStyle:#next. SystemBrowser start
claus
parents:
diff changeset
   711
     View defaultStyle:#motif. SystemBrowser start
claus
parents:
diff changeset
   712
     View defaultStyle:#iris. SystemBrowser start
claus
parents:
diff changeset
   713
     View defaultStyle:#st80. SystemBrowser start
claus
parents:
diff changeset
   714
     View defaultStyle:#normal. SystemBrowser start
claus
parents:
diff changeset
   715
    "
claus
parents:
diff changeset
   716
!
claus
parents:
diff changeset
   717
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   718
styleSheet:aViewStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   719
    "set the view style from a style-sheet"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   720
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   721
    StyleSheet := aViewStyle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   722
    DefaultStyle := (StyleSheet at:'name' ifAbsent:'unknown') asSymbol.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   723
    self updateAllStyleCaches.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   724
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   725
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   726
updateAllStyleCaches
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   727
    "reload all style caches in all view classes.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   728
     Needed after a style change or when a style file has been changed"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   729
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   730
    StyleSheet := ViewStyle fromFile:(DefaultStyle , '.style').
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   731
    StyleSheet fileReadFailed ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   732
	('***** WARNING: no styleSheet for ' , DefaultStyle , '-style.') errorPrintNL.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   733
	DefaultStyle ~~ #normal ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   734
	    DefaultStyle := #normal.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   735
	    StyleSheet := ViewStyle fromFile:(DefaultStyle , '.style').
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   736
        
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   737
	    StyleSheet fileReadFailed ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   738
		'***** WARNING: not even a styleSheet for normal-style (using defaults).' errorPrintNL.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   739
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   740
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   741
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   742
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   743
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   744
     tell all view classes to flush any
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   745
     cached style-data
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   746
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   747
    self changed:#style.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   748
    SimpleView updateStyleCache.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   749
    SimpleView allSubclassesDo:[:aClass |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   750
	(aClass class implements:#updateStyleCache) ifTrue:[aClass updateStyleCache].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   751
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   752
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   753
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   754
     View updateAllStyleCaches
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   755
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   756
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   757
135
claus
parents:
diff changeset
   758
updateStyleCache
claus
parents:
diff changeset
   759
    "this method gets some heavily used style stuff and keeps
claus
parents:
diff changeset
   760
     it in class-variables for faster access.
claus
parents:
diff changeset
   761
     Subclasses should redefine this to load any cached style-values
claus
parents:
diff changeset
   762
     into faster class variables as well. These should NOT do a 
claus
parents:
diff changeset
   763
     super updateStyleCache, since this method is called for all view-classes
claus
parents:
diff changeset
   764
     anyway."
claus
parents:
diff changeset
   765
claus
parents:
diff changeset
   766
    |bgGrey|
claus
parents:
diff changeset
   767
claus
parents:
diff changeset
   768
    "
claus
parents:
diff changeset
   769
     when coming here the first time, we read the styleSheet
claus
parents:
diff changeset
   770
     and keep the values in fast class variables
claus
parents:
diff changeset
   771
    "
claus
parents:
diff changeset
   772
    StyleSheet isNil ifTrue:[
claus
parents:
diff changeset
   773
	DefaultStyle := #normal.
claus
parents:
diff changeset
   774
	StyleSheet := ViewStyle fromFile:'normal.style'.
claus
parents:
diff changeset
   775
    ].
claus
parents:
diff changeset
   776
claus
parents:
diff changeset
   777
    Grey := StyleSheet viewGrey.
claus
parents:
diff changeset
   778
    Grey isNil ifTrue:[
claus
parents:
diff changeset
   779
	Grey := Color grey
claus
parents:
diff changeset
   780
    ].
claus
parents:
diff changeset
   781
    Grey := Grey on:Display.
claus
parents:
diff changeset
   782
151
claus
parents: 145
diff changeset
   783
    StyleSheet fileReadFailed ifTrue:[
claus
parents: 145
diff changeset
   784
	bgGrey := White
135
claus
parents:
diff changeset
   785
    ] ifFalse:[
151
claus
parents: 145
diff changeset
   786
	Display hasGreyscales ifTrue:[
claus
parents: 145
diff changeset
   787
	    bgGrey := Grey
claus
parents: 145
diff changeset
   788
	] ifFalse:[
claus
parents: 145
diff changeset
   789
	    bgGrey := White 
claus
parents: 145
diff changeset
   790
	]
135
claus
parents:
diff changeset
   791
    ].
151
claus
parents: 145
diff changeset
   792
    bgGrey := bgGrey on:Display.
135
claus
parents:
diff changeset
   793
claus
parents:
diff changeset
   794
    ViewSpacing := StyleSheet at:'viewSpacing'.
claus
parents:
diff changeset
   795
    ViewSpacing isNil ifTrue:[
claus
parents:
diff changeset
   796
	ViewSpacing := Display verticalPixelPerMillimeter rounded.
claus
parents:
diff changeset
   797
    ].
claus
parents:
diff changeset
   798
claus
parents:
diff changeset
   799
    DefaultBorderColor := StyleSheet colorAt:'borderColor' default:Black.
151
claus
parents: 145
diff changeset
   800
claus
parents: 145
diff changeset
   801
    StyleSheet fileReadFailed ifTrue:[
claus
parents: 145
diff changeset
   802
	DefaultBorderWidth := 1.
claus
parents: 145
diff changeset
   803
	DefaultShadowColor := Black.
claus
parents: 145
diff changeset
   804
	DefaultLightColor :=  White.
claus
parents: 145
diff changeset
   805
	DefaultFocusColor := Black.
claus
parents: 145
diff changeset
   806
	DefaultFocusBorderWidth := 2.
claus
parents: 145
diff changeset
   807
	DefaultViewBackgroundColor := bgGrey.
claus
parents: 145
diff changeset
   808
    ] ifFalse:[
claus
parents: 145
diff changeset
   809
	DefaultBorderWidth := StyleSheet at:'borderWidth' default:0.
claus
parents: 145
diff changeset
   810
	DefaultViewBackgroundColor := StyleSheet colorAt:'viewBackground' default:bgGrey.
claus
parents: 145
diff changeset
   811
	DefaultShadowColor := StyleSheet colorAt:'shadowColor'.
claus
parents: 145
diff changeset
   812
	DefaultLightColor := StyleSheet colorAt:'lightColor'.
claus
parents: 145
diff changeset
   813
	DefaultFocusColor := StyleSheet colorAt:'focusColor' default:Color red.
claus
parents: 145
diff changeset
   814
	DefaultFocusBorderWidth := StyleSheet at:'focusBorderWidth' default:2.
claus
parents: 145
diff changeset
   815
    ].
135
claus
parents:
diff changeset
   816
claus
parents:
diff changeset
   817
    DefaultFont := StyleSheet at:'font'.
claus
parents:
diff changeset
   818
    DefaultFont isNil ifTrue:[
claus
parents:
diff changeset
   819
	DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12.
claus
parents:
diff changeset
   820
    ].
claus
parents:
diff changeset
   821
claus
parents:
diff changeset
   822
    DefaultFont := DefaultFont on:Display.
claus
parents:
diff changeset
   823
claus
parents:
diff changeset
   824
    DefaultViewBackgroundColor isNil ifTrue:[
claus
parents:
diff changeset
   825
	'bad viewBackground in style - using white' errorPrintNL.
claus
parents:
diff changeset
   826
	DefaultViewBackgroundColor := White
claus
parents:
diff changeset
   827
    ].
claus
parents:
diff changeset
   828
!
claus
parents:
diff changeset
   829
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   830
viewSpacing
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   831
    "return a convenient number of pixels used to separate views (usually 1mm).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   832
     Having this value here at a common place makes certain that all views
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   833
     get a common look"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   834
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   835
    ^ ViewSpacing
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   836
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   837
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   838
!SimpleView class methodsFor:'resources'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   839
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   840
classResources
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   841
    "if not already loaded, get the classes resourcePack
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   842
     and return it"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   843
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   844
    ClassResources isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   845
	ClassResources := ResourcePack for:self.
140
claus
parents: 138
diff changeset
   846
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   847
    ^ ClassResources
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   848
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   849
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   850
classResources:aResourcePack
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   851
    "allow setting of the classResources"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   852
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   853
    ClassResources := aResourcePack
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   854
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   855
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   856
flushAllClassResources
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   857
    "flush all classes resource translations.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   858
     Needed after a resource file has changed."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   859
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   860
    ResourcePack flushCachedResourcePacks.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   861
    SimpleView flushClassResources.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   862
    SimpleView allSubclasses do:[:aClass |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   863
	aClass flushClassResources.
140
claus
parents: 138
diff changeset
   864
    ]
claus
parents: 138
diff changeset
   865
claus
parents: 138
diff changeset
   866
    "
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   867
     View flushAllClassResources
140
claus
parents: 138
diff changeset
   868
    "
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   869
    "to change the language:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   870
	Language := #english.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   871
	Smalltalk changed:#Language.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   872
	View flushAllClassResources
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   873
     or:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   874
	Language := #german.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   875
	Smalltalk changed:#Language.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   876
	View flushAllClassResources
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   877
    "     
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   878
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   879
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   880
flushClassResources
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   881
    "flush classes resource string translations.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   882
     Needed whenever a resource file or language has changed"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   883
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   884
    ClassResources := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   885
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   886
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   887
updateClassResources
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   888
    "flush classes resource string translations and reload them.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   889
     Needed whenever a resource file or language has changed"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   890
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   891
    ClassResources := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   892
    self classResources
135
claus
parents:
diff changeset
   893
! !
claus
parents:
diff changeset
   894
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   895
!SimpleView methodsFor:'ST-80 compatibility'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   896
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   897
checkForEvents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   898
    (shown and:[windowGroup notNil]) ifTrue:[windowGroup processEvents].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   899
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   900
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   901
sensor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   902
    "return the views sensor"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   903
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   904
    windowGroup notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   905
	^ windowGroup sensor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   906
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   907
    ^ nil
151
claus
parents: 145
diff changeset
   908
! !
claus
parents: 145
diff changeset
   909
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   910
!SimpleView methodsFor:'accessing-bg & border'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   911
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   912
borderColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   913
    "return my borderColor"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   914
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   915
    ^ borderColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   916
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   917
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   918
borderColor:aColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   919
    "set my borderColor"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   920
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   921
    (aColor ~~ borderColor) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   922
	borderColor := aColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   923
	drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   924
	    self setBorderColor
135
claus
parents:
diff changeset
   925
	]
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   926
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   927
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   928
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   929
borderShape:aForm
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   930
    "set the borderShape to aForm"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   931
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   932
    borderShape := aForm.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   933
    drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   934
	device setWindowBorderShape:(aForm id) in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   935
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   936
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   937
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   938
borderWidth
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   939
    "return my borderWidth"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   940
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   941
    ^ borderWidth
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   942
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   943
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   944
borderWidth:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   945
    "set my borderWidth"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   946
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   947
    (aNumber ~~ borderWidth) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   948
	borderWidth := aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   949
	drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   950
	    device setWindowBorderWidth:aNumber in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   951
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   952
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   953
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   954
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   955
level
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   956
    "return my level relative to superView (3D)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   957
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   958
    ^ level
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   959
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   960
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   961
level:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   962
    "set my level relative to superView (3D)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   963
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   964
    |oldMargin how|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   965
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   966
    (aNumber ~~ level and:[aNumber notNil]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   967
	self is3D ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   968
	    level := aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   969
	    oldMargin := margin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   970
	    margin := level abs.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   971
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   972
	    realized ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   973
		margin ~~ oldMargin ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   974
		    (margin > oldMargin) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   975
			how := #smaller
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   976
		    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   977
			how := #larger
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   978
		    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   979
		    self sizeChanged:how.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   980
		    self setInnerClip.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   981
		].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   982
		shown ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   983
		    self redrawEdges
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   984
		]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   985
	    ]
135
claus
parents:
diff changeset
   986
	]
claus
parents:
diff changeset
   987
    ]
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   988
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   989
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   990
lightColor:aColorOrImage
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   991
    "set the color to be used for lighted edges (3D only)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   992
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   993
    lightColor := aColorOrImage
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   994
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   995
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   996
margin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   997
    "return my margin - this is usually the level,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   998
     but can be more for some views"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
   999
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1000
    ^ margin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1001
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1002
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1003
shadowColor:aColorOrImage
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1004
    "set the color to be used for shadowed edges (3D only)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1005
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1006
    shadowColor := aColorOrImage
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1007
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1008
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1009
viewBackground:something
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1010
    "set the viewBackground to something, a color, image or form.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1011
     If its a color and we run on a color display, also set shadow and light
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1012
     colors - this means, that a red view will get light-red and dark-red
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1013
     edges."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1014
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1015
    something isColor ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1016
	device hasGreyscales ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1017
	    shadowColor := something darkened.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1018
	    lightColor := something lightened
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1019
	]
135
claus
parents:
diff changeset
  1020
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1021
    super viewBackground:something
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1022
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1023
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1024
viewShape:aForm
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1025
    "set the viewShape to aForm"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1026
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1027
    viewShape := aForm.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1028
    drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1029
	device setWindowShape:(aForm id) in:drawableId
135
claus
parents:
diff changeset
  1030
    ]
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1031
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1032
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1033
!SimpleView methodsFor:'accessing-dimensions'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1034
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1035
allInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1036
    "set all insets; positive makes the view smaller,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1037
     negative makes it larger."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1038
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1039
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1040
	insets := Array new:4.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1041
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1042
    insets atAllPut:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1043
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1044
    "force recomputation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1045
"/    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1046
"/        originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1047
"/    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1048
	self superViewChangedSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1049
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1050
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1051
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1052
bottom
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1053
    "return the y position of the actual bottom edge (in pixels)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1054
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1055
    ^ top + height - 1
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1056
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1057
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1058
bottom:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1059
    "set the corners y position"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1060
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1061
    self corner:(self corner x @ aNumber)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1062
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1063
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1064
bottomInset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1065
    "return the inset of the bottom edge; positive is to the top,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1066
     negative to the bottom"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1067
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1068
    insets isNil ifTrue:[^ 0].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1069
    ^ insets at:4
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1070
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1071
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1072
bottomInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1073
    "set the inset of the bottom edge; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1074
     positive is to the top (view becomes smaller),
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1075
     negative to the bottom (becomes larger)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1076
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1077
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1078
	insets := Array with:0 with:0 with:0 with:0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1079
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1080
    insets at:4 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1081
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1082
    "force recomputation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1083
"/    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1084
"/        originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1085
"/    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1086
	self superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1087
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1088
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1089
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1090
center
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1091
    "return the point at the center of the receiver (in pixels)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1092
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1093
    ^ (left + (width // 2)) @ (top + (height // 2))
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1094
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1095
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1096
center:newCenter
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1097
    "move the receiver so that newCenter, aPoint becomes the center point"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1098
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1099
    self origin:(newCenter - ((width // 2) @ (height // 2)))
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1100
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1101
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1102
computeCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1103
    "compute my corner; if I have a layoutObject,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1104
     relative origins or blocks to evaluate, compute it now ..
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1105
     Blocks may return relative values or nil; nil means: take current value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1106
     Returns the corner point in device coordinates (pixels)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1107
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1108
    |org newCorner newExt x y|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1109
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1110
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1111
     slowly migrating to use layoutObjects ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1112
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1113
    layout notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1114
	^ (layout rectangleRelativeTo:(superView viewRectangle)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1115
			    preferred:(self preferredBounds)) corner rounded
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1116
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1117
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1118
    (cornerRule notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1119
	newCorner := cornerRule value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1120
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1121
	 allow return of relative values ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1122
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1123
	x := newCorner x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1124
	y := newCorner y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1125
	x isNil ifTrue:[x := self corner x].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1126
	y isNil ifTrue:[y := self corner y].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1127
	((x isInteger not) or:[y isInteger not]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1128
	    newCorner := self cornerFromRelativeCorner:x@y 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1129
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1130
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1131
	(relativeCorner notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1132
	    newCorner := self cornerFromRelativeCorner:relativeCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1133
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1134
	    org := self computeOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1135
	    (extentRule notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1136
		newExt := extentRule value
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1137
	    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1138
		(relativeExtent notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1139
		    newExt := self extentFromRelativeExtent:relativeExtent 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1140
		]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1141
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1142
	    newCorner := org + newExt
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1143
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1144
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1145
    ^ newCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1146
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1147
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1148
computeExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1149
    "compute my extent; if I have a layoutObject, a relative extent 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1150
     or blocks to evaluate, compute it now ..
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1151
     There is one catch here, if the dimension was defined
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1152
     by origin/corner, compute them here and take that value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1153
     I.e. origin/corner definition has precedence over extent definition.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1154
     Returns the extent in device coordinates (pixels)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1155
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1156
    |newOrg newExt newCorner x y|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1157
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1158
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1159
     slowly migrating to use layoutObjects ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1160
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1161
    layout notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1162
	^ (layout rectangleRelativeTo:(superView viewRectangle)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1163
			    preferred:(self preferredBounds)) extent rounded
135
claus
parents:
diff changeset
  1164
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1165
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1166
    (cornerRule notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1167
	newCorner := cornerRule value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1168
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1169
	 allow return of relative values ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1170
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1171
	x := newCorner x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1172
	y := newCorner y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1173
	x isNil ifTrue:[x := self corner x].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1174
	y isNil ifTrue:[y := self corner y].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1175
	((x isInteger not) or:[y isInteger not]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1176
	    newCorner := self cornerFromRelativeCorner:x@y
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1177
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1178
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1179
	(relativeCorner notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1180
	    newCorner := self cornerFromRelativeCorner:relativeCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1181
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1182
	    (extentRule notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1183
		newExt := extentRule value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1184
		"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1185
		 allow return of relative values ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1186
		"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1187
		x := newExt x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1188
		y := newExt y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1189
		x isNil ifTrue:[x := width].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1190
		y isNil ifTrue:[y := height].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1191
		((x isInteger not) or:[y isInteger not]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1192
		    newExt := self extentFromRelativeExtent:x@y
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1193
		]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1194
	    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1195
		(relativeExtent notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1196
		    newExt := self extentFromRelativeExtent:relativeExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1197
		] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1198
		    newExt := (width @ height).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1199
		].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1200
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1201
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1202
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1203
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1204
    newCorner notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1205
	newOrg := self computeOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1206
	^ newCorner - newOrg.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1207
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1208
    ^ newExt.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1209
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1210
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1211
computeOrigin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1212
    "compute my origin; if I have a layoutObject, a relative origin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1213
     or blocks to evaluate, compute it now ..
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1214
     Blocks may return relative values or nil; nil means: take current value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1215
     Returns the origin point in device coordinates (pixels)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1216
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1217
    |newOrg x y|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1218
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1219
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1220
     slowly migrating to use layoutObjects ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1221
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1222
    layout notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1223
	^ (layout rectangleRelativeTo:(superView viewRectangle)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1224
			    preferred:(self preferredBounds)) origin rounded
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1225
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1226
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1227
    (originRule notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1228
	newOrg := originRule value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1229
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1230
	 allow return of relative values ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1231
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1232
	x := newOrg x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1233
	y := newOrg y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1234
	x isNil ifTrue:[x := self origin x].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1235
	y isNil ifTrue:[y := self origin y].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1236
	((x isInteger not) or:[y isInteger not]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1237
	    newOrg := self originFromRelativeOrigin:x@y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1238
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1239
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1240
	(relativeOrigin notNil) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1241
	    newOrg := self originFromRelativeOrigin:relativeOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1242
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1243
	    ^ (left @ top).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1244
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1245
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1246
    ^ newOrg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1247
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1248
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1249
corner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1250
    "return the lower right corner-point (in pixels)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1251
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1252
"/    ^ (left + width "- 1") @ (top + height "- 1")
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1253
    ^ (left + width - 1) @ (top + height - 1)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1254
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1255
    "Modified: 31.8.1995 / 16:51:40 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1256
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1257
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1258
corner:corner 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1259
    "set the views corner; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1260
     the corner argument may be:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1261
	 a point 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1262
	    where integer fields mean 'pixel-values'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1263
	    and float values mean 'relative-to-superview'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1264
	    and nil means 'take current value';
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1265
     or a block returning a point which is interpreted as above.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1266
     Please migrate to use layoutObjects, if possible."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1267
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1268
    |x y pixelCorner c|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1270
    corner isBlock ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1271
	cornerRule := corner.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1272
	drawableId notNil ifTrue:[    
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1273
	    pixelCorner := corner value
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1274
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1275
	    extentChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1276
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1277
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1278
	x := corner x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1279
	y := corner y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1280
	x isNil ifTrue:[x := self corner x].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1281
	y isNil ifTrue:[y := self corner y].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1282
	c := x @ y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1283
	((x isInteger not) or:[y isInteger not]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1284
	    relativeCorner := c.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1285
	    pixelCorner := self cornerFromRelativeCorner.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1286
	    pixelCorner isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1287
		extentChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1288
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1289
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1290
	    pixelCorner := c
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1291
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1292
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1293
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1294
    pixelCorner notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1295
	self pixelCorner:pixelCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1296
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1297
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1298
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1299
extent:extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1300
    "set the views extent; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1301
     extent may be:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1302
	a point 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1303
	    where integer fields mean 'pixel-values'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1304
	    and float values mean 'relative-to-superview'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1305
	    and nil means 'leave current value';
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1306
     or a block returning a point which is interpreted as above.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1307
     Be careful when using relative extents: rounding errors may
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1308
     accumulate. Better use origin/corner. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1309
     Best: migrate to use layour objects."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1310
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1311
    |w h pixelExtent e|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1312
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1313
    extent isBlock ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1314
	extentRule := extent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1315
	drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1316
	    pixelExtent := extent value
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1317
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1318
	    extentChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1319
	]
135
claus
parents:
diff changeset
  1320
    ] ifFalse:[
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1321
	w := extent x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1322
	h := extent y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1323
	w isNil ifTrue:[w := width].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1324
	h isNil ifTrue:[h := height].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1325
	e := w@h.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1326
	((w isInteger not) or:[h isInteger not]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1327
	    relativeExtent := e.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1328
	    pixelExtent := self extentFromRelativeExtent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1329
	    pixelExtent isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1330
		extentChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1331
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1332
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1333
	    pixelExtent := e
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1334
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1335
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1336
    pixelExtent notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1337
	self pixelExtent:pixelExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1338
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1339
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1340
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1341
geometryLayout
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1342
    "this method will vanish, as soon as all implementations of
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1343
     #layout: are removed ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1344
     (conflict for example in label>>layout:).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1345
     DO NOT USE #geometryLayout: in your code; it will be removed without
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1346
     notice."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1347
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1348
    ^ here layout
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1349
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1350
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1351
geometryLayout:aLayoutObject
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1352
    "this method will vanish, as soon as all implementations of
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1353
     #layout: are removed ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1354
     (conflict for example in label>>layout:).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1355
     DO NOT USE #geometryLayout: in your code; it will be removed without
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1356
     notice."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1357
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1358
    here layout:aLayoutObject
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1359
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1360
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1361
height:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1362
    "set the views height in pixels"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1363
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1364
    self extent:(width @ aNumber)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1365
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1366
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1367
heightIncludingBorder
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1368
    "return my height including border 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1369
     (this is my height as seen from the outside view;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1370
      while #height returns the height as seen by myself)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1371
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1372
    ^ height + (2*borderWidth)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1373
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1374
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1375
horizontalInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1376
    "set the insets of the left/right edge; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1377
     positive makes it smaller, negative makes it larger"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1378
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1379
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1380
	insets := Array with:0 with:0 with:0 with:0
135
claus
parents:
diff changeset
  1381
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1382
    insets at:1 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1383
    insets at:3 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1384
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1385
    "force recomputation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1386
"/    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1387
"/        originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1388
"/    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1389
	self superViewChangedSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1390
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1391
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1392
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1393
innerHeight
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1394
    "return the height of the view minus any 3D-shadow-borders"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1395
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1396
    (margin == 0) ifTrue:[^ height].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1397
    ^ height - (2 * margin)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1398
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1399
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1400
innerWidth
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1401
    "return the width of the view minus any 3D-shadow-borders"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1402
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1403
    (level == 0) ifTrue:[^ width].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1404
    ^ width - (2 * margin)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1405
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1406
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1407
inset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1408
    "set all insets; positive makes the view smaller,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1409
     negative makes it larger."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1410
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1411
    self allInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1412
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1413
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1414
layout
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1415
    "return the layout object which controls my geometry.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1416
     Currently, this is nil in most cases, and my geometry is
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1417
     defined by relativeOrigin/relativeCorner/relativeExtent,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1418
     originRule/extentRule/cornerRule and inset.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1419
     Applications should be changed to use layoutObjects,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1420
     since the above listed instance variables will vanish."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1421
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1422
    ^ layout
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1423
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1424
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1425
layout:aLayoutObject
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1426
    "set the layout object which controls my geometry.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1427
     Currently, this is almost nowhere used but views will be
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1428
     incrementally changed to use this new geometry management."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1429
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1430
    layout := aLayoutObject.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1431
    superView isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1432
	originChanged := cornerChanged := extentChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1433
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1434
	self superViewChangedSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1435
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1436
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1437
    "Modified: 19.9.1995 / 16:17:25 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1438
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1439
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1440
left
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1441
    "return the x position of the left border (in pixels)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1442
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1443
    ^ left
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1444
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1445
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1446
left:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1447
    "set the x position"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1448
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1449
    self origin:(aNumber @ top)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1450
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1451
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1452
left:newLeft top:newTop width:newWidth height:newHeight
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1453
    "another way of specifying origin and extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1454
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1455
    self origin:(newLeft @ newTop) extent:(newWidth @ newHeight)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1456
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1457
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1458
leftInset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1459
    "return the inset of the left edge; positive is to the right,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1460
     negative to the left"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1461
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1462
    insets isNil ifTrue:[^ 0].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1463
    ^ insets at:1 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1464
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1465
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1466
leftInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1467
    "set the inset of the left edge; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1468
     positive is to the right (view becomes smaller),
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1469
     negative to the left (becomes larger)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1470
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1471
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1472
	insets := Array with:0 with:0 with:0 with:0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1473
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1474
    insets at:1 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1475
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1476
    "force recomputation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1477
"/    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1478
"/        originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1479
"/    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1480
	self superViewChangedSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1481
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1482
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1483
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1484
makeFullyVisible
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1485
    "make sure, that the view is fully visible by shifting it
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1486
     into the visible screen area if nescessary.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1487
     This method will be moved to StandardSystemView ..."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1488
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1489
    |devBot devRight newTop newLeft|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1490
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1491
    newTop := top.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1492
    newLeft := left.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1493
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1494
    ((top + height) > (devBot := device height)) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1495
	newTop := devBot - height
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1496
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1497
    ((left + width) > (devRight := device width)) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1498
	newLeft := devRight - width
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1499
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1500
    (newTop < 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1501
	newTop := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1502
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1503
    (newLeft < 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1504
	newLeft := 0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1505
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1506
    ((newTop ~~ top) or:[newLeft ~~ left]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1507
	self origin:newLeft @ newTop
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1508
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1509
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1510
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1511
origin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1512
    "return the origin (in pixels)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1513
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1514
    ^ left@top
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1515
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1516
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1517
origin:origin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1518
    "set the views origin; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1519
     origin may be:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1520
	a point 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1521
	    where integer fields mean 'pixel-values'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1522
	    and float values mean 'relative-to-superview'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1523
	    and nil means 'take current value';
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1524
     or a block returning a point which is interpreted as above.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1525
     Please migrate to use layout objects."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1526
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1527
    |newLeft newTop pixelOrigin o|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1528
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1529
    origin isBlock ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1530
	originRule := origin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1531
	drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1532
	    pixelOrigin := origin value
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1533
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1534
	    originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1535
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1536
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1537
	o := origin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1538
	newLeft := origin x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1539
	newTop := origin y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1540
	newLeft isNil ifTrue:[newLeft := left].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1541
	newTop isNil ifTrue:[newTop := top].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1542
	o := newLeft @ newTop.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1543
	((newLeft isInteger not) or:[newTop isInteger not]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1544
	    relativeOrigin := o.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1545
	    pixelOrigin := self originFromRelativeOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1546
	    pixelOrigin isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1547
		originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1548
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1549
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1550
	    pixelOrigin := o
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1551
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1552
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1553
    pixelOrigin notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1554
	self pixelOrigin:pixelOrigin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1555
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1556
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1557
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1558
origin:origin corner:corner 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1559
    "set both origin and extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1560
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1561
    |newLeft newTop newRight newBot|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1562
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1563
    "do it as one operation if possible"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1564
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1565
    origin isBlock ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1566
	corner isBlock ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1567
	    newLeft := origin x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1568
	    newLeft isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1569
		newTop := origin y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1570
		newTop isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1571
		    newRight := corner x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1572
		    newRight isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1573
			newBot := corner y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1574
			newBot isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1575
			    self pixelOrigin:origin corner:corner 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1576
			]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1577
		    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1578
		]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1579
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1580
	]
135
claus
parents:
diff changeset
  1581
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1582
    self origin:origin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1583
    self corner:corner 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1584
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1585
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1586
origin:origin extent:extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1587
    "set both origin and extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1588
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1589
    |newLeft newTop newWidth newHeight|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1590
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1591
    "do it as one operation if possible"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1592
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1593
    origin isBlock ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1594
	extent isBlock ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1595
	    newLeft := origin x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1596
	    newLeft isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1597
		newTop := origin y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1598
		newTop isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1599
		    newWidth := extent x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1600
		    newWidth isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1601
			newHeight := extent y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1602
			newHeight isInteger ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1603
			    self pixelOrigin:origin extent:extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1604
			]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1605
		    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1606
		]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1607
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1608
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1609
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1610
    self extent:extent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1611
    self origin:origin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1612
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1613
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1614
originRelativeTo:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1615
    "return the origin (in pixels) relative to a superView,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1616
     or relative to the rootView (if the aView argument is nil).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1617
     If the receiver is nonNil and not a subview of aView, return nil."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1618
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1619
    |currentView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1620
     org  "{ Class: Point }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1621
     sumX "{ Class: SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1622
     sumY "{ Class: SmallInteger }" |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1623
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1624
    currentView := self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1625
    sumX := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1626
    sumY := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1627
    [currentView notNil] whileTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1628
	(currentView == aView) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1629
	    ^ (sumX @ sumY)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1630
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1631
	org := currentView origin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1632
	sumX := sumX + org x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1633
	sumY := sumY + org y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1634
	currentView := currentView superView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1635
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1636
    (aView isNil or:[aView == RootView]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1637
	"return relative to screen ..."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1638
	^ (sumX @ sumY)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1639
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1640
    ^ nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1641
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1642
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1643
     |top sub1 sub2|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1644
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1645
     top := StandardSystemView new.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1646
     top extent:200@200.   
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1647
     sub1 := View origin:0.2 @ 0.2 corner:0.8 @ 0.8 in:top.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1648
     sub2 := Button origin:0.3 @ 0.3 corner:0.7 @ 0.7 in:sub1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1649
     top openAndWait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1650
     Transcript show:'button in top:'; showCr:(sub2 originRelativeTo:top).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1651
     Transcript show:'button on screen:'; showCr:(sub2 originRelativeTo:nil).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1652
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1653
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1654
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1655
relativeCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1656
    "return the relative corner or nil"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1657
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1658
    ^ relativeCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1659
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1660
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1661
relativeCorner:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1662
    "set the relative corner"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1663
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1664
    relativeCorner := aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1665
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1666
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1667
relativeExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1668
    "return the relative extent or nil"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1669
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1670
    ^ relativeExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1671
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1672
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1673
relativeExtent:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1674
    "set the relative extent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1675
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1676
    relativeExtent := aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1677
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1678
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1679
relativeOrigin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1680
    "return the relative origin or nil"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1681
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1682
    ^ relativeOrigin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1683
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1684
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1685
relativeOrigin:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1686
    "set the relative origin"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1687
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1688
    relativeOrigin := aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1689
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1690
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1691
right
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1692
    "return the x position of the right edge  (in pixels)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1693
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1694
    ^ left + width - 1
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1695
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1696
    "Modified: 31.8.1995 / 19:31:10 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1697
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1698
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1699
right:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1700
    "set the corners x position"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1701
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1702
    self corner:(aNumber @ self corner y)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1703
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1704
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1705
rightInset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1706
    "return the inset of the right edge; positive is to the left,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1707
     negative to the right"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1708
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1709
    insets isNil ifTrue:[^ 0].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1710
    ^ insets at:3 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1711
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1712
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1713
rightInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1714
    "set the inset of the right edge; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1715
     positive is to the left (view becomes smaller), 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1716
     negative to the right (becomes larger)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1717
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1718
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1719
	insets := Array with:0 with:0 with:0 with:0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1720
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1721
    insets at:3 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1722
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1723
    "force recomputation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1724
"/    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1725
"/        originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1726
"/    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1727
	self superViewChangedSize.
135
claus
parents:
diff changeset
  1728
"/    ]
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1729
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1730
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1731
sizeFixed:aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1732
    "set/clear the fix-size attribute, if supported by concrete subclasses.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1733
     Views which want to resize themselfes as appropriate to their contents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1734
     should cease to do so and take their current size if sizeFixed is set to
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1735
     true. Currently, only supported by Labels.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1736
     This does NOT prevent the window manager from resizing the view, 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1737
     instead it tell the view to NOT resize ITSELF.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1738
     Added here to provide a common protocol for all views."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1739
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1740
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1741
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1742
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1743
top
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1744
    "return the y position of the top border"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1745
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1746
    ^ top
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1747
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1748
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1749
top:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1750
    "set the y position"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1751
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1752
    self origin:(left @ aNumber)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1753
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1754
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1755
topInset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1756
    "return the inset of the top edge; positive is to the bottom,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1757
     negative to the top"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1758
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1759
    insets isNil ifTrue:[^ 0].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1760
    ^ insets at:2 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1761
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1762
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1763
topInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1764
    "set the inset of the top edge; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1765
     positive is to the bottom (view becomes smaller),
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1766
     negative to the top (becomes larger)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1767
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1768
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1769
	insets := Array with:0 with:0 with:0 with:0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1770
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1771
    insets at:2 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1772
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1773
    "force recomputation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1774
"/    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1775
"/        originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1776
"/    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1777
	self superViewChangedSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1778
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1779
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1780
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1781
verticalInset:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1782
    "set the insets of the top/bottom edge; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1783
     positive makes it smaller, negative makes it larger"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1784
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1785
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1786
	insets := Array with:0 with:0 with:0 with:0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1787
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1788
    insets at:2 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1789
    insets at:4 put:aNumber.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1790
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1791
    "force recomputation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1792
"/    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1793
"/        originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1794
"/    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1795
	self superViewChangedSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1796
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1797
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1798
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1799
width:aNumber
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1800
    "set the views width in pixels"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1801
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1802
    self extent:(aNumber @ height)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1803
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1804
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1805
widthIncludingBorder
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1806
    "return my width including border
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1807
     (this is my width as seen from the outside view;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1808
      while #width returns the width as seen by myself)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1809
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1810
    ^ width + (2*borderWidth)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1811
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1812
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1813
!SimpleView methodsFor:'accessing-hierarchy'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1814
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1815
lower
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1816
    "bring to back"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1817
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1818
    drawableId isNil ifTrue:[self create].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1819
    device lowerWindow:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1820
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1821
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1822
     Transcript topView lower
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1823
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1824
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1825
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1826
raise
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1827
    "bring to front"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1828
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1829
    drawableId isNil ifTrue:[self create].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1830
    device raiseWindow:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1831
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1832
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1833
     Transcript topView raise
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1834
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1835
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1836
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1837
subViews
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1838
    "return the collection of subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1839
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1840
    ^ subViews
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1841
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1842
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1843
subViews:aListOfViews
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1844
    "set the collection of subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1845
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1846
    subViews := aListOfViews.
135
claus
parents:
diff changeset
  1847
    subViews notNil ifTrue:[
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1848
	subViews do:[:view |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1849
	    view superView:self
135
claus
parents:
diff changeset
  1850
	]
claus
parents:
diff changeset
  1851
    ]
claus
parents:
diff changeset
  1852
!
claus
parents:
diff changeset
  1853
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1854
superView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1855
    "return my superView"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1856
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1857
    ^ superView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1858
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1859
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1860
superView:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1861
    "set my superView to be aView"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1862
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1863
    superView := aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1864
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1865
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1866
topView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1867
    "return the topView - thats the one with no superview"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1868
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1869
    |v|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1870
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1871
    v := self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1872
    [v notNil] whileTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1873
	v superView isNil ifTrue:[^ v].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1874
	v := v superView
135
claus
parents:
diff changeset
  1875
    ].
claus
parents:
diff changeset
  1876
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1877
    ^ nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1878
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1879
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1880
!SimpleView methodsFor:'accessing-menus'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1881
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1882
menuHolder
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1883
    "who has the menu ? 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1884
     By default, I have it."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1885
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1886
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1887
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1888
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1889
menuMessage
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1890
    "Return the symbol sent to myself to aquire the menu"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1891
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1892
    ^ #middleButtonMenu
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1893
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1894
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1895
menuPerformer
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1896
    "who should perform the menu actions ? 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1897
     By default, I do it."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1898
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1899
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1900
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1901
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1902
yellowButtonMenu
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1903
    "actually, this should be called 'middleButtonMenu'.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1904
     But for ST-80 compatibility ....
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1905
     This method will vanish, once all views have controllers
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1906
     associated with them; for now, duplicate some code also found in
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1907
     controller."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1908
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1909
    |sym menuHolder|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1910
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1911
"/    middleButtonMenu notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1912
"/        "/
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1913
"/        "/ has been assigned a static middleButtonMenu
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1914
"/        "/ (or a cached menu)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1915
"/        "/
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1916
"/        ^ middleButtonMenu
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1917
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1918
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1919
    menuHolder := self menuHolder.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1920
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1921
    menuHolder notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1922
	sym := self menuMessage.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1923
	sym notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1924
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1925
	     mhmh - for backward compatibility, try to ask
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1926
	     the model first, then use the views menu.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1927
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1928
	    (menuHolder respondsTo:sym) ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1929
		(self respondsTo:sym) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1930
		    menuHolder := self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1931
		]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1932
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1933
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1934
	     ask the menuHolder for the menu
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1935
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1936
	    ^ menuHolder perform:sym.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1937
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1938
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1939
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  1940
    ^ nil
135
claus
parents:
diff changeset
  1941
! !
claus
parents:
diff changeset
  1942
claus
parents:
diff changeset
  1943
!SimpleView methodsFor:'accessing-misc'!
claus
parents:
diff changeset
  1944
193
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1945
beInvisible
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1946
    self hidden:true.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1947
    realized ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1948
	self unrealize
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1949
    ]
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1950
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1951
    "Created: 22.9.1995 / 15:29:01 / claus"
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1952
!
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1953
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1954
beVisible
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1955
    self hidden:false.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1956
    realized ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1957
	self realize
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1958
    ]
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1959
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1960
    "
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1961
     |top topFrame check list|
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1962
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1963
     top := StandardSystemView new.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1964
     top extent:150@400.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1965
     topFrame := VerticalPanelView origin:0.0@0.0 corner:1.0@0.4 in:top.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1966
     topFrame horizontalLayout:#leftSpace.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1967
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1968
     topFrame add:(check := CheckBox label:'hidden').
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1969
     check pressAction:[list beInvisible].
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1970
     check releaseAction:[list beVisible].
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1971
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1972
     list := ScrollableView for:SelectionInListView.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1973
     list origin:0.0@0.4 corner:1.0@1.0.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1974
     list list:#('foo' 'bar' 'baz').
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1975
     top add:list.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1976
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1977
     check turnOn.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1978
     list beInvisible.
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1979
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1980
     top open
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1981
    "
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1982
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1983
    "Created: 22.9.1995 / 15:50:33 / claus"
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1984
!
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  1985
135
claus
parents:
diff changeset
  1986
bitGravity
claus
parents:
diff changeset
  1987
    "return the bitGravity - thats the direction where the contents will move
claus
parents:
diff changeset
  1988
     when the the view is resized."
claus
parents:
diff changeset
  1989
claus
parents:
diff changeset
  1990
    ^ bitGravity
claus
parents:
diff changeset
  1991
!
claus
parents:
diff changeset
  1992
claus
parents:
diff changeset
  1993
bitGravity:gravity
claus
parents:
diff changeset
  1994
    "set the bitGravity - thats the direction where the contents will move
claus
parents:
diff changeset
  1995
     when the view is resized."
claus
parents:
diff changeset
  1996
claus
parents:
diff changeset
  1997
    bitGravity ~~ gravity ifTrue:[
claus
parents:
diff changeset
  1998
	bitGravity := gravity.
claus
parents:
diff changeset
  1999
	drawableId notNil ifTrue:[
claus
parents:
diff changeset
  2000
	    device setBitGravity:gravity in:drawableId
claus
parents:
diff changeset
  2001
	]
claus
parents:
diff changeset
  2002
    ]
claus
parents:
diff changeset
  2003
!
claus
parents:
diff changeset
  2004
claus
parents:
diff changeset
  2005
canDrop:anObjectOrCollection
claus
parents:
diff changeset
  2006
    "return true, if anObjectOrCollection can be
claus
parents:
diff changeset
  2007
     dropped in the receiver. This method should be
claus
parents:
diff changeset
  2008
     redefined in views which can take objects"
claus
parents:
diff changeset
  2009
claus
parents:
diff changeset
  2010
    ^ false
claus
parents:
diff changeset
  2011
!
claus
parents:
diff changeset
  2012
153
claus
parents: 151
diff changeset
  2013
clipRect:aRectangle
claus
parents: 151
diff changeset
  2014
    "set the clipping rectangle for drawing (in logical coordinates);
claus
parents: 151
diff changeset
  2015
     a nil argument turn off clipping (i.e. whole view is drawable).
claus
parents: 151
diff changeset
  2016
     Redefined to care for any margin."
claus
parents: 151
diff changeset
  2017
claus
parents: 151
diff changeset
  2018
    |x y w h|
claus
parents: 151
diff changeset
  2019
claus
parents: 151
diff changeset
  2020
    aRectangle isNil ifTrue:[
claus
parents: 151
diff changeset
  2021
	clipRect isNil ifTrue:[^ self].
claus
parents: 151
diff changeset
  2022
	gcId notNil ifTrue:[
claus
parents: 151
diff changeset
  2023
	    device noClipIn:gcId
claus
parents: 151
diff changeset
  2024
	]
claus
parents: 151
diff changeset
  2025
    ] ifFalse:[
claus
parents: 151
diff changeset
  2026
	clipRect notNil ifTrue:[
claus
parents: 151
diff changeset
  2027
	    (clipRect = aRectangle) ifTrue:[^ self]
claus
parents: 151
diff changeset
  2028
	].
claus
parents: 151
diff changeset
  2029
	gcId notNil ifTrue:[
claus
parents: 151
diff changeset
  2030
	    x := aRectangle left.
claus
parents: 151
diff changeset
  2031
	    y := aRectangle top.
claus
parents: 151
diff changeset
  2032
	    w := aRectangle width.
claus
parents: 151
diff changeset
  2033
	    h := aRectangle height.
claus
parents: 151
diff changeset
  2034
	    transformation notNil ifTrue:[
claus
parents: 151
diff changeset
  2035
		x := transformation applyToX:x.
claus
parents: 151
diff changeset
  2036
		y := transformation applyToY:y.
claus
parents: 151
diff changeset
  2037
		w := transformation applyScaleX:w.
claus
parents: 151
diff changeset
  2038
		h := transformation applyScaleY:h.
claus
parents: 151
diff changeset
  2039
	    ].
claus
parents: 151
diff changeset
  2040
	    (x isMemberOf:SmallInteger) ifFalse:[
claus
parents: 151
diff changeset
  2041
		w := w + (x - x truncated).
claus
parents: 151
diff changeset
  2042
		x := x truncated
claus
parents: 151
diff changeset
  2043
	    ].
claus
parents: 151
diff changeset
  2044
	    (y isMemberOf:SmallInteger) ifFalse:[
claus
parents: 151
diff changeset
  2045
		h := h + (y - y truncated).
claus
parents: 151
diff changeset
  2046
		y := y truncated
claus
parents: 151
diff changeset
  2047
	    ].
claus
parents: 151
diff changeset
  2048
	    (w isMemberOf:SmallInteger) ifFalse:[
claus
parents: 151
diff changeset
  2049
		w := w truncated + 1
claus
parents: 151
diff changeset
  2050
	    ].
claus
parents: 151
diff changeset
  2051
	    (h isMemberOf:SmallInteger) ifFalse:[
claus
parents: 151
diff changeset
  2052
		h := h truncated + 1
claus
parents: 151
diff changeset
  2053
	    ].
claus
parents: 151
diff changeset
  2054
	    x < margin ifTrue:[
claus
parents: 151
diff changeset
  2055
		x := margin.
claus
parents: 151
diff changeset
  2056
	    ].
claus
parents: 151
diff changeset
  2057
	    y < margin ifTrue:[
claus
parents: 151
diff changeset
  2058
		y := margin.
claus
parents: 151
diff changeset
  2059
	    ].
claus
parents: 151
diff changeset
  2060
	    x + w - 1 >= (width-margin) ifTrue:[
claus
parents: 151
diff changeset
  2061
		w := width - margin - x
claus
parents: 151
diff changeset
  2062
	    ].
claus
parents: 151
diff changeset
  2063
	    y + h - 1 >= (height-margin) ifTrue:[
claus
parents: 151
diff changeset
  2064
		h := height - margin - y
claus
parents: 151
diff changeset
  2065
	    ].
claus
parents: 151
diff changeset
  2066
	    device setClipX:x y:y width:w height:h in:gcId
claus
parents: 151
diff changeset
  2067
	]
claus
parents: 151
diff changeset
  2068
    ].
claus
parents: 151
diff changeset
  2069
    clipRect := aRectangle
claus
parents: 151
diff changeset
  2070
!
claus
parents: 151
diff changeset
  2071
claus
parents: 151
diff changeset
  2072
fullName
claus
parents: 151
diff changeset
  2073
    "return my full name to be used for resource-access"
claus
parents: 151
diff changeset
  2074
claus
parents: 151
diff changeset
  2075
    superView notNil ifTrue:[
claus
parents: 151
diff changeset
  2076
	^ superView fullName , '.' , name
claus
parents: 151
diff changeset
  2077
    ].
claus
parents: 151
diff changeset
  2078
    ^ name
claus
parents: 151
diff changeset
  2079
!
claus
parents: 151
diff changeset
  2080
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2081
hidden
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2082
    "return true, if the view does not want to be realized
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2083
     automatically when superview is realized"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2084
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2085
    self obsoleteMethodWarning:'use #hiddenOnRealize'.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2086
    ^ hiddenOnRealize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2087
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2088
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2089
hidden:aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2090
    "if the argument is true, the receiver view will not
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2091
     be realized automatically when superview is realized"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2092
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2093
    self obsoleteMethodWarning:'use #hiddenOnRealize:'.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2094
    hiddenOnRealize := aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2095
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2096
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2097
hiddenOnRealize:aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2098
    "if the argument is true, the receiver view will not
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2099
     be mapped automatically when the superview is realized.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2100
     The hiddenOnRealize flag is useful to create views which are
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2101
     to be made visible conditionally or later."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2102
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2103
    hiddenOnRealize := aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2104
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2105
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2106
inputOnly
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2107
    "return true, if this view is an input-only view;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2108
     input only views are transparent and can be layed on top of a view to
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2109
     catch its input"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2110
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2111
    ^ false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2112
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2113
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2114
is3D
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2115
    "return true, if my style is some kind of 3D style
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2116
     This is OBSOLETE and will be removed."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2117
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2118
    ^ styleSheet is3D
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2119
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2120
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2121
isHiddenOnRealize:aBoolean
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2122
    "return true, if the receiver will NOT be mapped when
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2123
     realized. False otherwise.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2124
     The hiddenOnRealize flag is useful to create views which are
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2125
     to be made visible conditionally or later."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2126
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2127
    ^ hiddenOnRealize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2128
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2129
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2130
isPopUpView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2131
    "return true, if this view should be put on top (raised) automatically.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2132
     usually this is true for alertBoxes etc."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2133
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2134
    ^ false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2135
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2136
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2137
name
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2138
    "return my name component to be used for resource-access"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2139
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2140
    ^ name
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2141
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2142
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2143
name:aString
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2144
    "set my name component to be used for resource-access"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2145
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2146
    name := aString
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2147
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2148
153
claus
parents: 151
diff changeset
  2149
processName
claus
parents: 151
diff changeset
  2150
    "return a string to be shown in the process monitor"
claus
parents: 151
diff changeset
  2151
claus
parents: 151
diff changeset
  2152
    ^ self name
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2153
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2154
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2155
shown
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2156
    "return true if the view is shown; false if not.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2157
     Shown means: the view is mapped and is not completely covered."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2158
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2159
    ^ shown
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2160
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2161
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2162
styleSheet 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2163
    "return the styleSheet. This is set at early view-creation time,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2164
     from the defaultStyleSheet which is valid at that time.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2165
     It is not affected by later defaultStyle changes"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2166
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2167
    ^ styleSheet
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2168
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2169
    "Created: 10.9.1995 / 11:02:20 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2170
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2171
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2172
viewGravity
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2173
    "return the viewGravity - thats the direction where the view will move
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2174
     when the superView is resized."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2175
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2176
    ^ viewGravity
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2177
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2178
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2179
viewGravity:gravity
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2180
    "set the viewGravity - thats the direction where the view will move
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2181
     when the superView is resized."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2182
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2183
    viewGravity ~~ gravity ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2184
	viewGravity := gravity.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2185
	drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2186
	    device setWindowGravity:gravity in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2187
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2188
    ]
140
claus
parents: 138
diff changeset
  2189
! !
claus
parents: 138
diff changeset
  2190
claus
parents: 138
diff changeset
  2191
!SimpleView methodsFor:'accessing-mvc'!
claus
parents: 138
diff changeset
  2192
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2193
aspect:aspectSymbol
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2194
    "ST-80 style updating: If a views aspectSymbol is nonNil, 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2195
     it will respond to changes of this aspect from the model.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2196
     Alias for aspectMessage: for ST-80 compatibility."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2197
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2198
    self aspectMessage:aspectSymbol
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2199
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2200
140
claus
parents: 138
diff changeset
  2201
controller
claus
parents: 138
diff changeset
  2202
    "return the controller. For non MVC views, return nil"
claus
parents: 138
diff changeset
  2203
claus
parents: 138
diff changeset
  2204
    ^ controller
claus
parents: 138
diff changeset
  2205
!
claus
parents: 138
diff changeset
  2206
claus
parents: 138
diff changeset
  2207
controller:aController
claus
parents: 138
diff changeset
  2208
    "set the controller"
claus
parents: 138
diff changeset
  2209
claus
parents: 138
diff changeset
  2210
    controller := aController.
claus
parents: 138
diff changeset
  2211
    controller notNil ifTrue:[
claus
parents: 138
diff changeset
  2212
	controller view:self.
135
claus
parents:
diff changeset
  2213
    ]
claus
parents:
diff changeset
  2214
!
claus
parents:
diff changeset
  2215
140
claus
parents: 138
diff changeset
  2216
model
135
claus
parents:
diff changeset
  2217
    ^ nil
claus
parents:
diff changeset
  2218
!
claus
parents:
diff changeset
  2219
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2220
windowGroup
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2221
    "return the window group. For old style views, return nil"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2222
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2223
    ^ windowGroup
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2224
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2225
140
claus
parents: 138
diff changeset
  2226
windowGroup:aGroup
claus
parents: 138
diff changeset
  2227
    "set the window group."
claus
parents: 138
diff changeset
  2228
claus
parents: 138
diff changeset
  2229
    windowGroup := aGroup
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2230
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2231
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2232
!SimpleView methodsFor:'accessing-transformation'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2233
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2234
heightOfContents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2235
    "return the height of the contents in logical units 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2236
     - defaults to views visible area here.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2237
    This method MUST be redefined in all view classess which are
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2238
    going to be scrolled AND show data which has different size than
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2239
    the view. For example, a view showing A4-size documents should return
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2240
    the number of vertical pixels such a document has on this device.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2241
    A view showing a bitmap of height 1000 should return 1000.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2242
    If not redefined, scrollbars have no way of knowing the actual size
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2243
    of the contents being shown. This is called by scrollBars to compute
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2244
    the relative height of the document vs. the views actual size.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2245
    The value returned here must be based on a scale of 1, since users
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2246
    of this will scale as appropriate."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2247
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2248
    ^ self innerHeight max:(self maxSubViewBottom)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2249
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2250
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2251
maxSubViewBottom 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2252
"/    subViews isNil ifTrue:[^ 0].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2253
"/    ^ subViews inject:0 into:[:maxSoFar :sub | (sub top + sub height) max:maxSoFar].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2254
      ^ 0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2255
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2256
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2257
maxSubViewRight 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2258
"/    subViews isNil ifTrue:[^ 0].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2259
"/    ^ subViews inject:0 into:[:maxSoFar :sub | (sub left + sub width) max:maxSoFar].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2260
    ^ 0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2261
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2262
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2263
scale
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2264
    "return the scale factor (as point) of the transformation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2265
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2266
    transformation isNil ifTrue:[^ 1].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2267
    ^ transformation scale
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2268
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2270
scale:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2271
    "set the scale factor of the transformation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2272
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2273
    transformation isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2274
	aPoint = 1 ifTrue:[^ self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2275
	transformation := WindowingTransformation scale:aPoint translation:0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2276
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2277
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2278
    transformation scale:aPoint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2279
    self computeInnerClip
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2280
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2281
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2282
setViewOrigin:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2283
    "set the viewOrigin - i.e. virtually scroll without redrawing"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2284
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2285
    |p|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2286
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2287
    p := aPoint negated.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2288
    transformation isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2289
	transformation := WindowingTransformation scale:1 translation:p 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2290
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2291
	transformation translation:p 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2292
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2293
    clipRect notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2294
	self setInnerClip.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2295
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2296
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2297
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2298
transformation 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2299
    "return the transformation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2300
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2301
    |vP org|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2302
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2303
    transformation isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2304
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2305
	 fake a transformation, if I have a non-nil window
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2306
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2307
	window notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2308
	    superView isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2309
		org := 0 @ 0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2310
	    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2311
		org := self origin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2312
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2313
	    vP := org extent:(self extent).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2314
	    ^ WindowingTransformation window:window viewport:vP
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2315
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2316
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2317
    ^ transformation
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2318
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2319
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2320
viewOrigin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2321
    "return the viewOrigin; thats the coordinate of the contents 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2322
     which is shown topLeft in the view 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2323
     (i.e. the origin of the visible part of the contents)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2324
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2325
    transformation isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2326
	^ 0@0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2327
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2328
    ^ transformation translation negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2329
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2330
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2331
viewRectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2332
    "return the inside area"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2333
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2334
    |m2|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2335
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2336
"/    innerClipRect notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2337
"/        ^ innerClipRect
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2338
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2339
    m2 := margin + margin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2340
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2341
    ^ (margin @ margin) extent:((width - m2) @ (height - m2))
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2342
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2343
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2344
viewport:aRectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2345
    "define my extend in my superviews coordinate-system."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2346
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2347
"/    |relW relH relX relY winW winH|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2348
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2349
    viewport := aRectangle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2350
    self dimensionFromViewport
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2351
"/
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2352
"/    superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2353
"/        superView window isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2354
"/            winW := 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2355
"/            winH := 1
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2356
"/        ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2357
"/            winW := superView window width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2358
"/            winH := superView window height
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2359
"/        ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2360
"/        relW := (aRectangle width / winW) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2361
"/        relH := (aRectangle height / winH) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2362
"/        relX := (aRectangle left / winW) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2363
"/        relY := (aRectangle top / winH) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2364
"/        self origin:(relX @ relY) extent:(relW @ relH)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2365
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2366
"/
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2367
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2368
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2369
widthOfContents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2370
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2371
    ^ self innerWidth max:(self maxSubViewRight)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2372
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2373
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2374
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2375
window
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2376
    "return my window (i.e. logical coordinate space).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2377
     If there is no window, return the extent."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2378
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2379
    window isNil ifTrue:[^ width @ height].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2380
    ^ window
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2381
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2382
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2383
window:aRectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2384
    "define my window (i.e. logical coordinate space)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2385
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2386
    window := aRectangle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2387
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2388
	subViews do:[:s |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2389
	    s superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2390
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2391
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2392
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2393
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2394
    viewport isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2395
	viewport := aRectangle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2396
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2397
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2398
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2399
    superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2400
	self superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2401
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2402
	originChanged := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2403
	extentChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2404
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2405
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2406
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2407
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2408
window:aRectangle viewport:vRect
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2409
    window := aRectangle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2410
    self viewport:vRect.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2411
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2412
	subViews do:[:s |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2413
	    s superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2414
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2415
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2416
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2417
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2418
xOriginOfContents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2419
    "return the x coordinate of the viewOrigin in pixels; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2420
     used by scrollBars to compute thumb position within the document."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2421
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2422
    ^ self viewOrigin x
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2423
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2424
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2425
yOriginOfContents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2426
    "return the y coordinate of the viewOrigin in pixels; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2427
     used by scrollBars to compute thumb position within the document."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2428
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2429
    ^ self viewOrigin y
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2430
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2431
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2432
!SimpleView methodsFor:'adding & removing components'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2433
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2434
add:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2435
    "add a component (either a view or gadget) to the collection of
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2436
     subComponents."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2437
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2438
    self addComponent:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2439
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2440
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2441
add:aComponent in:aRectangleOrLayoutFrame 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2442
    "for ST-80 compatibility.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2443
     add a component in some frame; the argument may be either a rectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2444
     with relative coordinates, or an instance of LayoutFrame, specifying
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2445
     both relative coordinates and the insets."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2446
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2447
"/ old code:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2448
"/    |origin corner l|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2449
"/
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2450
"/    origin := aRectangleOrLayoutFrame origin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2451
"/    origin := origin x asFloat @ origin y asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2452
"/    corner := aRectangleOrLayoutFrame corner.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2453
"/    corner := corner x asFloat @ corner y asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2454
"/    aComponent origin:origin corner:corner.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2455
"/
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2456
"/    (aRectangleOrLayoutFrame isMemberOf:Rectangle) ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2457
"/        aComponent leftInset:aRectangleOrLayoutFrame leftOffset.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2458
"/        aComponent rightInset:aRectangleOrLayoutFrame rightOffset negated.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2459
"/        aComponent topInset:aRectangleOrLayoutFrame topOffset.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2460
"/        aComponent bottomInset:aRectangleOrLayoutFrame bottomOffset negated.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2461
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2462
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2463
"/ new (being validated):
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2464
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2465
    |l|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2466
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2467
    (aRectangleOrLayoutFrame isMemberOf:Rectangle) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2468
	l := aRectangleOrLayoutFrame asLayout.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2469
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2470
	l := aRectangleOrLayoutFrame
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2471
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2472
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2473
"/  will soon be replaced by:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2474
"/    aComponent layout:l.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2475
    aComponent geometryLayout:l.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2476
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2477
    self addComponent:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2478
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2479
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2480
addComponent:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2481
    "components (i.e. gadgets or lightweight views) are being prepared. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2482
     Dont use this right now for non-views"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2483
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2484
    aComponent isView ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2485
	self addSubView:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2486
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2487
	components isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2488
	    components := OrderedCollection new
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2489
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2490
	components add:aComponent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2491
	aComponent setParentViewIn:self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2492
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2493
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2494
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2495
addSubView:newView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2496
    "add a view to the collection of subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2497
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2498
    subViews isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2499
	subViews := OrderedCollection with:newView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2500
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2501
	subViews add:newView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2502
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2503
    self setParentViewIn:newView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2504
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2505
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2506
addSubView:newView after:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2507
    "add a view to the collection of subviews after another view.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2508
     This makes sense, in Panels and other layout views, to enter a new
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2509
     element at some defined place."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2510
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2511
    subViews isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2512
	subViews := OrderedCollection with:newView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2513
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2514
	aView isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2515
	    subViews add:newView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2516
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2517
	    subViews add:newView after:aView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2518
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2519
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2520
    self setParentViewIn:newView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2521
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2522
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2523
addSubView:newView before:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2524
    "add a view to the collection of subviews before another view.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2525
     This makes sense, in Panels and other layout views, to enter a new
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2526
     element at some defined place."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2527
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2528
    subViews isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2529
	subViews := OrderedCollection with:newView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2530
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2531
	aView isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2532
	    subViews addFirst:newView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2533
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2534
	    subViews add:newView before:aView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2535
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2536
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2537
    self setParentViewIn:newView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2538
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2539
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2540
addSubView:aView in:bounds borderWidth:bw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2541
    "for ST-80 V2.x compatibility"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2542
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2543
    aView borderWidth:bw.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2544
    self add:aView in:bounds.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2545
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2546
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2547
addSubView:aView viewport:aRectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2548
    "ST-80 V2.x compatibility:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2549
     Adds aView to the views list of subviews and uses the
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2550
     existing subviews window and the new viewport to position it.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2551
     This method may be removed in future versions."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2552
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2553
    self addSubView:aView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2554
    aView viewport:aRectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2555
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2556
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2557
addSubView:aView window:aWindowRectangle viewport:aViewportRectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2558
    "ST-80 V2.x compatibility:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2559
     Adds aView to the views list of subviews and uses 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2560
     aWindowRectangle and aViewportRectangle to position it.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2561
     This method may be removed in future versions."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2562
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2563
    self addSubView:aView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2564
    aView window:aWindowRectangle viewport:aViewportRectangle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2565
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2566
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2567
component:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2568
    "components (i.e. gadgets or lightweight views) are being prepared. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2569
     Dont use this right now for non-views"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2570
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2571
    aComponent origin:0.0@0.0 corner:1.0@1.0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2572
    aComponent isView ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2573
	self addSubView:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2574
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2575
	components := OrderedCollection with:aComponent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2576
	aComponent setParentViewIn:self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2577
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2578
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2579
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2580
destroySubViews
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2581
    "remove all subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2582
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2583
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2584
	subViews copy do:[:aSubView |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2585
	    aSubView destroy.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2586
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2587
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2588
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2589
    "Modified: 5.9.1995 / 22:35:36 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2590
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2591
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2592
removeComponent:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2593
    "components (i.e. gadgets or lightweight views) are being prepared. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2594
     Dont use this right now for non-views"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2595
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2596
    aComponent isView ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2597
	self removeSubView:aComponent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2598
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2599
	components isNil ifTrue:[^self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2600
	components remove:aComponent ifAbsent:[].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2601
	aComponent parent:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2602
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2603
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2604
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2605
removeSubView:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2606
    "remove a view from the collection of subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2607
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2608
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2609
	subViews remove:aView ifAbsent:[nil].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2610
	(subViews size == 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2611
	    subViews := nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2612
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2613
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2614
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2615
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2616
setParentViewIn:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2617
    "common code for addSubView* methods"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2618
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2619
    aView superView:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2620
    (aView device ~~ device) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2621
	'VIEW: warning subview (' errorPrint. aView class name errorPrint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2622
	') has different device than me (' errorPrint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2623
	self class name errorPrint. ').' errorPrintNL.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2624
	aView device:device
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2625
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2626
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2627
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2628
!SimpleView methodsFor:'change & update'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2629
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2630
update:aspect with:aParameter from:changedObject
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2631
    "an update request"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2632
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2633
    aspect == #sizeOfView ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2634
	"one of the views we depend on changed its size"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2635
	^ self superViewChangedSize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2636
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2637
    ^super update:aspect with:aParameter from:changedObject
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2638
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2639
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2640
!SimpleView methodsFor:'copying'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2641
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2642
shallowCopyForFinalization
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2643
    "redefined for faster creation of finalization copies
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2644
     (only device, gcId and drawableId are needed)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2645
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2646
    |aCopy|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2647
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2648
    aCopy := DeviceViewHandle basicNew.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2649
    aCopy setDevice:device id:drawableId gcId:gcId.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2650
    ^ aCopy
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2651
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2652
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2653
!SimpleView methodsFor:'cursor animation'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2654
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2655
showBusyWhile:aBlock
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2656
    "evaluate some time consuming block, while doing this,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2657
     show a spinning wheel cursor"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2658
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2659
    |ok bitmaps cursors mask process oldCursor|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2660
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2661
    oldCursor := cursor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2662
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2663
    ok := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2664
    bitmaps := #('wheel1' 'wheel2' 'wheel3' 'wheel4') 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2665
	       collect:[:name |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2666
		   |f|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2667
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2668
		   f := Form fromFile:(name , '.xbm').
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2669
		   f isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2670
			('no bitmap file: ' , name , '.xbm') errorPrintNL.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2671
			ok := false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2672
		   ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2673
		   f
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2674
	       ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2675
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2676
    mask := Form fromFile:'wheelm.xbm'.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2677
    mask isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2678
	('no bitmap file: ' , mask , '.xbm') errorPrintNL.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2679
	ok := false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2680
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2681
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2682
    ok ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2683
	self cursor:Cursor wait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2684
	aBlock valueNowOrOnUnwindDo:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2685
	    self cursor:oldCursor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2686
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2687
    ] ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2688
	cursors := bitmaps collect:[:form | (Cursor sourceForm:form
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2689
						      maskForm:mask
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2690
							  hotX:8
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2691
							  hotY:8) on:device].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2692
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2693
	process := [
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2694
		    (Delay forSeconds:0.25) wait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2695
		    [true] whileTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2696
			cursors do:[:curs |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2697
			    self cursor:curs.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2698
			    (Delay forSeconds:0.05) wait
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2699
			]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2700
		    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2701
		   ] fork.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2702
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2703
	Processor activeProcess priority:7.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2704
	aBlock valueNowOrOnUnwindDo:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2705
	    Processor activeProcess priority:8.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2706
	    process terminate.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2707
	    self cursor:oldCursor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2708
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2709
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2710
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2711
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2712
     View new realize showBusyWhile:[10 timesRepeat:[3000 factorial]]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2713
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2714
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2715
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2716
!SimpleView methodsFor:'edge drawing'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2717
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2718
drawBottomEdge
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2719
    "draw bottom 3D edge into window frame"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2720
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2721
    self drawBottomEdgeLevel:level
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2722
		      shadow:shadowColor 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2723
		      light:lightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2724
		      halfShadow:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2725
		      halfLight:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2726
		      style:nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2727
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2728
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2729
drawBottomEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2730
    |botFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2731
     count "{ Class: SmallInteger }" 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2732
     b r|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2733
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2734
    count := level.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2735
    count == 0 ifTrue:[^ self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2736
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2737
    (count < 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2738
	botFg := lightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2739
	count := count negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2740
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2741
	((edgeStyle == #soft) and:[level > 1]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2742
	    botFg := halfShadowColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2743
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2744
	    botFg := shadowColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2745
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2746
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2747
    super paint:botFg.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2748
    super lineWidth:0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2749
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2750
    r := width - 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2751
    0 to:(count - 1) do:[:i |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2752
	b := height - 1 - i.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2753
	super displayDeviceLineFromX:i y:b toX:(r - i) y:b
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2754
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2755
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2756
    ((edgeStyle == #soft) and:[level > 1]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2757
	b := height - 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2758
	super paint:shadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2759
	super displayDeviceLineFromX:1 y:b toX:r y:b. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2760
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2761
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2762
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2763
drawEdges
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2764
    "draw all of my 3D edges"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2765
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2766
    self drawEdgesForX:0 y:0 width:width height:height level:level
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2767
		shadow:shadowColor 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2768
		light:lightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2769
		halfShadow:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2770
		halfLight:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2771
		style:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2772
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2773
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2774
drawEdgesForX:x y:y width:w height:h level:l
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2775
    "draw 3D edges into a rectangle"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2776
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2777
    self drawEdgesForX:x y:y width:w height:h level:l 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2778
		shadow:shadowColor 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2779
		light:lightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2780
		halfShadow:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2781
		halfLight:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2782
		style:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2783
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2784
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2785
drawEdgesForX:x y:y width:w height:h level:l 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2786
		shadow:shadowColor light:lightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2787
		halfShadow:halfShadowColor halfLight:halfLightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2788
		style:edgeStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2789
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2790
    "draw 3D edges into a rectangle"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2791
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2792
    |topLeftFg botRightFg topLeftHalfFg botRightHalfFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2793
     count "{ Class: SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2794
     r     "{ Class: SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2795
     b     "{ Class: SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2796
     xi    "{ Class: SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2797
     yi    "{ Class: SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2798
     run paint|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2799
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2800
    count := l.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2801
    (count < 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2802
	topLeftFg := shadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2803
	botRightFg := lightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2804
	topLeftHalfFg := halfShadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2805
	botRightHalfFg := halfLightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2806
	count := count negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2807
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2808
	topLeftFg := lightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2809
	botRightFg := shadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2810
	topLeftHalfFg := halfLightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2811
	botRightHalfFg := halfShadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2812
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2813
    topLeftHalfFg isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2814
	topLeftHalfFg := topLeftFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2815
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2816
    botRightHalfFg isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2817
	botRightHalfFg := botRightFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2818
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2819
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2820
    r := x + w - 1. "right"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2821
    b := y + h - 1. "bottom"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2822
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2823
    super lineWidth:0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2824
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2825
    "top and left edges"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2826
    ((edgeStyle == #soft) and:["l" count > 0]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2827
	paint := topLeftHalfFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2828
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2829
	paint := topLeftFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2830
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2831
    super paint:paint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2832
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2833
    0 to:(count - 1) do:[:i |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2834
	run := y + i.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2835
	super displayDeviceLineFromX:x y:run toX:r y:run. "top"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2836
	run := x + i.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2837
	super displayDeviceLineFromX:run y:y toX:run y:b  "left"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2838
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2839
    (edgeStyle == #soft) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2840
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2841
	super paint:topLeftFg.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2842
	super displayDeviceLineFromX:x y:y toX:r y:y. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2843
	super displayDeviceLineFromX:x y:y toX:x y:b        
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2844
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2845
	(l > 2) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2846
	    super paint:Black.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2847
	    super displayDeviceLineFromX:x y:y toX:r y:y. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2848
	    super displayDeviceLineFromX:x y:y toX:x y:b. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2849
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2850
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2851
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2852
    xi := x + 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2853
    yi := y + 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2854
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2855
"/ does not look good
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2856
"/ style == #st80 iftrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2857
"/  yi := yi + 1
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2858
"/ ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2859
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2860
    "bottom and right edges"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2861
    (edgeStyle == #soft "new:" and:[count > 1]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2862
	paint := botRightHalfFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2863
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2864
	paint := botRightFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2865
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2866
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2867
    super paint:paint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2868
    0 to:(count - 1) do:[:i |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2869
	run := b - i.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2870
	super displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2871
	run := r - i.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2872
	super displayDeviceLineFromX:run y:yi-1 toX:run y:b.  "right"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2873
	xi := xi + 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2874
	yi := yi + 1
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2875
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2876
    ((edgeStyle == #soft) and:[l > 1]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2877
	super paint:Black "shadowColor".
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2878
	super displayDeviceLineFromX:(x + (1 - 1)) y:b toX:r y:b. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2879
	super displayDeviceLineFromX:r y:(y + (1 - 1)) toX:r y:b        
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2880
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2881
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2882
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2883
drawLeftEdge
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2884
    "draw left 3D edge into window frame"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2885
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2886
    self drawLeftEdgeLevel:level
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2887
		    shadow:shadowColor 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2888
		     light:lightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2889
		     halfShadow:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2890
		     halfLight:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2891
		     style:nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2892
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2893
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2894
drawLeftEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2895
    |leftFg leftHalfFg paint b
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2896
     count "{ Class: SmallInteger }" |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2897
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2898
    count := level.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2899
    count == 0 ifTrue:[^ self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2900
    
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2901
    (count < 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2902
	leftFg := shadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2903
	leftHalfFg := halfShadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2904
	count := count negated.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2905
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2906
	leftFg := lightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2907
	leftHalfFg := halfLightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2908
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2909
    leftHalfFg isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2910
	leftHalfFg := leftFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2911
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2912
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2913
    ((edgeStyle == #soft) and:[level > 0]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2914
	paint := leftHalfFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2915
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2916
	paint := leftFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2917
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2918
    super paint:paint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2919
    super lineWidth:0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2920
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2921
    b := height - 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2922
    0 to:(count - 1) do:[:i |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2923
	super displayDeviceLineFromX:i y:i toX:i y:(b - i)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2924
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2925
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2926
    ((edgeStyle == #soft) and:[level > 2]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2927
	super paint:Black.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2928
	super displayDeviceLineFromX:0 y:0 toX:0 y:b. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2929
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2930
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2931
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2932
drawRightEdge
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2933
    "draw right 3D edge into window frame"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2934
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2935
    self drawRightEdgeLevel:level
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2936
		     shadow:shadowColor 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2937
		      light:lightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2938
		      halfShadow:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2939
		      halfLight:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2940
		      style:nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2941
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2942
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2943
drawRightEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2944
    |rightFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2945
     count "{ Class: SmallInteger }" 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2946
     r b|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2947
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2948
    count := level.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2949
    count == 0 ifTrue:[^ self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2950
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2951
    (count < 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2952
	rightFg := lightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2953
	count := count negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2954
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2955
	((edgeStyle == #soft) and:[level > 1]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2956
	    rightFg := halfShadowColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2957
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2958
	    rightFg := shadowColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2959
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2960
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2961
    super paint:rightFg.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2962
    super lineWidth:0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2963
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2964
    b := height - 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2965
    0 to:(count - 1) do:[:i |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2966
	r := width - 1 - i.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2967
	super displayDeviceLineFromX:r y:i toX:r y:(b - i)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2968
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2969
    ((edgeStyle == #soft) and:[level > 1]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2970
	r := width - 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2971
	super paint:shadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2972
	super displayDeviceLineFromX:r y:1 toX:r y:b. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2973
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2974
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2975
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2976
drawTopEdge
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2977
    "draw top 3D edge into window frame"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2978
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2979
    self drawTopEdgeLevel:level
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2980
		   shadow:shadowColor 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2981
		    light:lightColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2982
		    halfShadow:nil 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2983
		    halfLight:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2984
		    style:nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2985
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2986
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2987
drawTopEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2988
    |topFg topHalfFg paint r
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2989
     count "{ Class: SmallInteger }" |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2990
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2991
    count := level.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2992
    count == 0 ifTrue:[^ self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2993
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2994
    (count < 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2995
	topFg := shadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2996
	topHalfFg := halfShadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2997
	count := count negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2998
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  2999
	topFg := lightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3000
	topHalfFg := halfLightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3001
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3002
    topHalfFg isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3003
	topHalfFg := topFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3004
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3005
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3006
    ((edgeStyle == #soft) and:[level > 0]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3007
	paint := topHalfFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3008
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3009
	paint := topFg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3010
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3011
    super paint:paint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3012
    super lineWidth:0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3013
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3014
    r := width - 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3015
    0 to:(count - 1) do:[:i |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3016
	super displayDeviceLineFromX:i y:i toX:(r - i) y:i
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3017
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3018
    ((edgeStyle == #soft) and:[level > 2]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3019
	super paint:Black.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3020
	super displayDeviceLineFromX:0 y:0 toX:r y:0. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3021
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3022
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3023
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3024
redrawEdges
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3025
    "redraw my edges (if any)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3026
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3027
    (level ~~ 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3028
	shown ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3029
	    self clipRect:nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3030
	    self drawEdges.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3031
	    self clipRect:innerClipRect
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3032
	]                  
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3033
    ]                  
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3034
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3035
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3036
!SimpleView methodsFor:'enumerating subviews'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3037
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3038
allSubViewsDo:aBlock
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3039
    "evaluate aBlock for all subviews (recursively)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3040
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3041
    (subViews isNil or:[subViews isEmpty]) ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3042
	subViews do:[:aSubview |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3043
	    aSubview withAllSubViewsDo:aBlock
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3044
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3045
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3046
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3047
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3048
withAllSubViewsDo:aBlock
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3049
    "evaluate aBlock for the receiver and all subviews (recursively)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3050
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3051
    aBlock value:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3052
    self allSubViewsDo:aBlock
135
claus
parents:
diff changeset
  3053
! !
claus
parents:
diff changeset
  3054
claus
parents:
diff changeset
  3055
!SimpleView methodsFor:'event handling'!
claus
parents:
diff changeset
  3056
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3057
buttonPress:button x:x y:y
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3058
    "button was pressed - if its the middle button 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3059
     and there is a middleButtonMenu, show it.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3060
     If both a model and a menuSelector is is defined, ask the model for
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3061
     the menu and launch it. The menu is supposed to return an actionSelector
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3062
     which in turn is sent to the model."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3063
271
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3064
    |menu menuPerformer actionSelector actionArg haveArg|
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3065
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3066
    components notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3067
	components do:[:aComponent |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3068
	    |thisFrame|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3069
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3070
	    thisFrame := aComponent frame.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3071
	    (thisFrame containsPointX:x y:y) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3072
		aComponent buttonPress:button x:x - thisFrame left
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3073
					      y:y - thisFrame top.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3074
		^ self
140
claus
parents: 138
diff changeset
  3075
	    ]
claus
parents: 138
diff changeset
  3076
	]
claus
parents: 138
diff changeset
  3077
    ].
claus
parents: 138
diff changeset
  3078
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3079
    ((button == 2) or:[button == #menu]) ifTrue:[
271
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3080
	haveArg := false.
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3081
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3082
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3083
	 try ST-80 style menus first:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3084
	 if there is a model, and a menuMessage is defined,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3085
	 ask model for the menu and launch that if non-nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3086
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3087
	menu := self yellowButtonMenu.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3088
	menu notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3089
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3090
	     got one, launch the menu. It is supposed
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3091
	     to return an actionSelector.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3092
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3093
	    menuPerformer := self menuPerformer.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3094
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3095
	     a temporary kludge: subMenus dont know about 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3096
	     actionSelectors yet ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3097
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3098
	    menu receiver isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3099
		menu receiver:menuPerformer
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3100
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3101
	    actionSelector := menu startUp.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3102
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3103
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3104
	     mhmh - kludge for selectors with argument
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3105
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3106
	    (actionSelector isMemberOf:Array) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3107
		actionArg := actionSelector at:2.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3108
		actionSelector := actionSelector at:1.
271
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3109
		haveArg := true.
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3110
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3111
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3112
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3113
	     mhmh - ST-80 seems to send some to the model and
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3114
	     others (copy/cut/paste) to the controller/view
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3115
	     Simulate this behavior, by looking what the model responds to.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3116
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3117
	    (actionSelector notNil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3118
	    and:[actionSelector isSymbol]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3119
		(menuPerformer respondsTo:actionSelector) ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3120
		    (self respondsTo:actionSelector) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3121
			menuPerformer := self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3122
		    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3123
		].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3124
		actionSelector numArgs ~~ 0 ifTrue:[
271
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3125
		    haveArg ifFalse:[
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3126
			"/ for checkToggle entries, pass its value
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3127
			actionArg := menu checkToggleAt:actionSelector
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3128
		    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3129
		    menuPerformer perform:actionSelector with:actionArg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3130
		] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3131
		    menuPerformer perform:actionSelector
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3132
		]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3133
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3134
	    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3135
	].
140
claus
parents: 138
diff changeset
  3136
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3137
    super buttonPress:button x:x y:y
271
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3138
88d9e485a5da menu handling: if entry is a checkToggleEntry, AND selector wants an argument,
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
  3139
    "Modified: 3.12.1995 / 14:20:02 / cg"
193
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  3140
!
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
  3141
140
claus
parents: 138
diff changeset
  3142
configureX:x y:y width:newWidth height:newHeight
claus
parents: 138
diff changeset
  3143
    "my size has changed by window manager action"
claus
parents: 138
diff changeset
  3144
180
claus
parents: 176
diff changeset
  3145
    |how anyEdge mustRedrawBottomEdge mustRedrawRightEdge p|
claus
parents: 176
diff changeset
  3146
claus
parents: 176
diff changeset
  3147
    (superView isNil 
claus
parents: 176
diff changeset
  3148
    and:[drawableId notNil]) ifTrue:[
claus
parents: 176
diff changeset
  3149
	"/ have to be careful - some window managers (motif) wrap another
claus
parents: 176
diff changeset
  3150
	"/ view around and the reported origin is relative to that.
claus
parents: 176
diff changeset
  3151
	"/ not relative to the screen.
claus
parents: 176
diff changeset
  3152
	p := device translatePoint:0@0 from:drawableId to:device rootWindowId.
claus
parents: 176
diff changeset
  3153
	left := p x.
claus
parents: 176
diff changeset
  3154
	top := p y.
claus
parents: 176
diff changeset
  3155
    ] ifFalse:[
claus
parents: 176
diff changeset
  3156
	left := x.
claus
parents: 176
diff changeset
  3157
	top := y.
claus
parents: 176
diff changeset
  3158
    ].
140
claus
parents: 138
diff changeset
  3159
    ((width ~~ newWidth) or:[height ~~ newHeight]) ifTrue:[
claus
parents: 138
diff changeset
  3160
	realized ifFalse:[
claus
parents: 138
diff changeset
  3161
	    width := newWidth.
claus
parents: 138
diff changeset
  3162
	    height := newHeight.
claus
parents: 138
diff changeset
  3163
	    extentChanged := true.
claus
parents: 138
diff changeset
  3164
	    ^ self
claus
parents: 138
diff changeset
  3165
	].
claus
parents: 138
diff changeset
  3166
claus
parents: 138
diff changeset
  3167
	((newWidth <= width) and:[newHeight <= height]) ifTrue:[
claus
parents: 138
diff changeset
  3168
	    how := #smaller
claus
parents: 138
diff changeset
  3169
	].
claus
parents: 138
diff changeset
  3170
claus
parents: 138
diff changeset
  3171
	level ~~ 0 ifTrue:[
claus
parents: 138
diff changeset
  3172
	    mustRedrawBottomEdge := newHeight < height.
claus
parents: 138
diff changeset
  3173
	    mustRedrawRightEdge := newWidth < width.
claus
parents: 138
diff changeset
  3174
	    anyEdge := mustRedrawBottomEdge or:[mustRedrawRightEdge]
claus
parents: 138
diff changeset
  3175
	] ifFalse:[
claus
parents: 138
diff changeset
  3176
	    anyEdge := false
claus
parents: 138
diff changeset
  3177
	].
claus
parents: 138
diff changeset
  3178
claus
parents: 138
diff changeset
  3179
	width := newWidth.
claus
parents: 138
diff changeset
  3180
	height := newHeight.
claus
parents: 138
diff changeset
  3181
claus
parents: 138
diff changeset
  3182
	"recompute inner-clip if needed"
claus
parents: 138
diff changeset
  3183
	self setInnerClip.
claus
parents: 138
diff changeset
  3184
claus
parents: 138
diff changeset
  3185
	"
claus
parents: 138
diff changeset
  3186
	 must first process pending exposes;
claus
parents: 138
diff changeset
  3187
	 otherwise, those may be drawn at a wrong position
claus
parents: 138
diff changeset
  3188
	"
claus
parents: 138
diff changeset
  3189
	windowGroup notNil ifTrue:[
claus
parents: 138
diff changeset
  3190
	    windowGroup processExposeEvents
claus
parents: 138
diff changeset
  3191
	].
claus
parents: 138
diff changeset
  3192
	self sizeChanged:how.
claus
parents: 138
diff changeset
  3193
claus
parents: 138
diff changeset
  3194
	(anyEdge and:[shown]) ifTrue:[
claus
parents: 138
diff changeset
  3195
	    self clipRect:nil.
claus
parents: 138
diff changeset
  3196
	    mustRedrawBottomEdge ifTrue:[
claus
parents: 138
diff changeset
  3197
		self drawBottomEdge
claus
parents: 138
diff changeset
  3198
	    ].
claus
parents: 138
diff changeset
  3199
	    mustRedrawRightEdge ifTrue:[
claus
parents: 138
diff changeset
  3200
		self drawRightEdge
claus
parents: 138
diff changeset
  3201
	    ].
claus
parents: 138
diff changeset
  3202
	    self clipRect:innerClipRect
claus
parents: 138
diff changeset
  3203
	]
claus
parents: 138
diff changeset
  3204
    ]
138
claus
parents: 137
diff changeset
  3205
!
claus
parents: 137
diff changeset
  3206
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3207
coveredBy:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3208
    "the receiver has been covered by another view;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3209
     we are not interrested in that here (but see modalBox for more)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3210
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3211
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3212
destroyed
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3213
    "view has been destroyed by someone else (usually window system)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3214
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3215
    shown := false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3216
    super destroyed
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3217
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3218
135
claus
parents:
diff changeset
  3219
exposeX:x y:y width:w height:h
claus
parents:
diff changeset
  3220
    "a low level redraw event from device
claus
parents:
diff changeset
  3221
      - let subclass handle the redraw and take care of edges here"
claus
parents:
diff changeset
  3222
claus
parents:
diff changeset
  3223
    |leftEdge topEdge rightEdge botEdge anyEdge nx ny nw nh old|
claus
parents:
diff changeset
  3224
claus
parents:
diff changeset
  3225
    nw := w.
claus
parents:
diff changeset
  3226
    nh := h.
claus
parents:
diff changeset
  3227
    nx := x.
claus
parents:
diff changeset
  3228
    ny := y.
claus
parents:
diff changeset
  3229
claus
parents:
diff changeset
  3230
    anyEdge := false.
claus
parents:
diff changeset
  3231
claus
parents:
diff changeset
  3232
    "
claus
parents:
diff changeset
  3233
     check if there is a need to draw an edge (i.e. if margin is hit)
claus
parents:
diff changeset
  3234
    "
claus
parents:
diff changeset
  3235
    (margin ~~ 0) ifTrue:[
claus
parents:
diff changeset
  3236
	leftEdge := false.
claus
parents:
diff changeset
  3237
	topEdge := false.
claus
parents:
diff changeset
  3238
	rightEdge := false.
claus
parents:
diff changeset
  3239
	botEdge := false.
claus
parents:
diff changeset
  3240
	transformation notNil ifTrue:[
claus
parents:
diff changeset
  3241
	    "
claus
parents:
diff changeset
  3242
	     need device coordinates for this test
claus
parents:
diff changeset
  3243
	    "
claus
parents:
diff changeset
  3244
	    nx := transformation applyToX:nx.
claus
parents:
diff changeset
  3245
	    ny := transformation applyToY:ny.
claus
parents:
diff changeset
  3246
	    nw := transformation applyScaleX:nw.
claus
parents:
diff changeset
  3247
	    nh := transformation applyScaleY:nh.
claus
parents:
diff changeset
  3248
	].
claus
parents:
diff changeset
  3249
	"
claus
parents:
diff changeset
  3250
	 adjust expose rectangle, to exclude the margin.
claus
parents:
diff changeset
  3251
	 Care for rounding errors ...
claus
parents:
diff changeset
  3252
	"
claus
parents:
diff changeset
  3253
	(nx isMemberOf:SmallInteger) ifFalse:[
claus
parents:
diff changeset
  3254
	    old := nx.
claus
parents:
diff changeset
  3255
	    nx := nx truncated.
claus
parents:
diff changeset
  3256
	    nw := nw + (nx - old).
claus
parents:
diff changeset
  3257
	].
claus
parents:
diff changeset
  3258
	(ny isMemberOf:SmallInteger) ifFalse:[
claus
parents:
diff changeset
  3259
	    old := ny.
claus
parents:
diff changeset
  3260
	    ny := ny truncated.
claus
parents:
diff changeset
  3261
	    nh := nh + (ny - old).
claus
parents:
diff changeset
  3262
	].
claus
parents:
diff changeset
  3263
	(nw isMemberOf:SmallInteger) ifFalse:[
claus
parents:
diff changeset
  3264
	    nw := nw truncated + 1
claus
parents:
diff changeset
  3265
	].
claus
parents:
diff changeset
  3266
	(nh isMemberOf:SmallInteger) ifFalse:[
claus
parents:
diff changeset
  3267
	    nh := nh truncated + 1
claus
parents:
diff changeset
  3268
	].
claus
parents:
diff changeset
  3269
	(nx < margin) ifTrue:[
claus
parents:
diff changeset
  3270
	    old := nx.
claus
parents:
diff changeset
  3271
	    nx := margin.
claus
parents:
diff changeset
  3272
	    nw := nw - (nx - old).
claus
parents:
diff changeset
  3273
	    leftEdge := anyEdge := true.
claus
parents:
diff changeset
  3274
	].
claus
parents:
diff changeset
  3275
	((nx + nw - 1) >= (width - margin)) ifTrue:[
claus
parents:
diff changeset
  3276
	    nw := (width - margin - nx).
claus
parents:
diff changeset
  3277
	    rightEdge := anyEdge := true.
claus
parents:
diff changeset
  3278
	].
claus
parents:
diff changeset
  3279
	(ny < margin) ifTrue:[
claus
parents:
diff changeset
  3280
	    old := ny.
claus
parents:
diff changeset
  3281
	    ny := margin.
claus
parents:
diff changeset
  3282
	    nh := nh - (ny - old).
claus
parents:
diff changeset
  3283
	    topEdge := anyEdge := true.
claus
parents:
diff changeset
  3284
	].
claus
parents:
diff changeset
  3285
	((ny + nh - 1) >= (height - margin)) ifTrue:[
claus
parents:
diff changeset
  3286
	    nh := (height - margin - ny).
claus
parents:
diff changeset
  3287
	    botEdge := anyEdge := true.
claus
parents:
diff changeset
  3288
	].
claus
parents:
diff changeset
  3289
	transformation notNil ifTrue:[
claus
parents:
diff changeset
  3290
	    "
claus
parents:
diff changeset
  3291
	     need logical coordinates for redraw
claus
parents:
diff changeset
  3292
	    "
claus
parents:
diff changeset
  3293
	    nx := transformation applyInverseToX:nx.
claus
parents:
diff changeset
  3294
	    ny := transformation applyInverseToY:ny.
claus
parents:
diff changeset
  3295
	    nw := transformation applyInverseScaleX:nw.
claus
parents:
diff changeset
  3296
	    nh := transformation applyInverseScaleY:nh.
claus
parents:
diff changeset
  3297
	].
claus
parents:
diff changeset
  3298
    ].
claus
parents:
diff changeset
  3299
claus
parents:
diff changeset
  3300
    "
claus
parents:
diff changeset
  3301
     redraw inside area
claus
parents:
diff changeset
  3302
    "
claus
parents:
diff changeset
  3303
    self redrawX:nx y:ny width:nw height:nh.
claus
parents:
diff changeset
  3304
claus
parents:
diff changeset
  3305
    "
claus
parents:
diff changeset
  3306
     redraw edge(s)
claus
parents:
diff changeset
  3307
    "
claus
parents:
diff changeset
  3308
    anyEdge ifTrue:[
claus
parents:
diff changeset
  3309
	self clipRect:nil.
claus
parents:
diff changeset
  3310
	(topEdge and:[leftEdge and:[botEdge and:[rightEdge]]]) ifTrue:[
claus
parents:
diff changeset
  3311
	    self drawEdges
claus
parents:
diff changeset
  3312
	] ifFalse:[
claus
parents:
diff changeset
  3313
	    topEdge ifTrue:[
claus
parents:
diff changeset
  3314
		self drawTopEdge
claus
parents:
diff changeset
  3315
	    ].
claus
parents:
diff changeset
  3316
	    leftEdge ifTrue:[
claus
parents:
diff changeset
  3317
		self drawLeftEdge
claus
parents:
diff changeset
  3318
	    ].
claus
parents:
diff changeset
  3319
	    botEdge ifTrue:[
claus
parents:
diff changeset
  3320
		self drawBottomEdge
claus
parents:
diff changeset
  3321
	    ].
claus
parents:
diff changeset
  3322
	    rightEdge ifTrue:[
claus
parents:
diff changeset
  3323
		self drawRightEdge
claus
parents:
diff changeset
  3324
	    ]
claus
parents:
diff changeset
  3325
	].
claus
parents:
diff changeset
  3326
	self clipRect:innerClipRect
claus
parents:
diff changeset
  3327
    ]
claus
parents:
diff changeset
  3328
!
claus
parents:
diff changeset
  3329
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3330
focusIn
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3331
    "got keyboard focus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3332
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3333
    self showFocus
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3334
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3335
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3336
focusOut
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3337
    "lost keyboard focus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3338
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3339
    self showNoFocus
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3340
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3341
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3342
hasKeyboardFocus:aBoolean
140
claus
parents: 138
diff changeset
  3343
    ^ self
claus
parents: 138
diff changeset
  3344
!
claus
parents: 138
diff changeset
  3345
claus
parents: 138
diff changeset
  3346
keyPress:key x:x y:y
claus
parents: 138
diff changeset
  3347
    "a key has been pressed. If there are components,
claus
parents: 138
diff changeset
  3348
     pass it to the corresponding one. 
claus
parents: 138
diff changeset
  3349
     Otherwise, forward it to the superview, if there is any."
claus
parents: 138
diff changeset
  3350
claus
parents: 138
diff changeset
  3351
    components notNil ifTrue:[
claus
parents: 138
diff changeset
  3352
	components do:[:aComponent |
claus
parents: 138
diff changeset
  3353
	    |thisFrame|
claus
parents: 138
diff changeset
  3354
claus
parents: 138
diff changeset
  3355
	    thisFrame := aComponent frame.
claus
parents: 138
diff changeset
  3356
	    (thisFrame containsPointX:x y:y) ifTrue:[
claus
parents: 138
diff changeset
  3357
		aComponent keyPress:key x:x - thisFrame left
claus
parents: 138
diff changeset
  3358
					y:y - thisFrame top.
claus
parents: 138
diff changeset
  3359
		^ self
claus
parents: 138
diff changeset
  3360
	    ]
135
claus
parents:
diff changeset
  3361
	]
claus
parents:
diff changeset
  3362
    ].
claus
parents:
diff changeset
  3363
140
claus
parents: 138
diff changeset
  3364
    x >= 0 ifTrue:[
claus
parents: 138
diff changeset
  3365
	superView notNil ifTrue:[
claus
parents: 138
diff changeset
  3366
	    WindowEvent
claus
parents: 138
diff changeset
  3367
		sendEvent:#keyPress:x:y:
claus
parents: 138
diff changeset
  3368
		arguments:(Array with:key with:0 with:0)
claus
parents: 138
diff changeset
  3369
		view:superView
135
claus
parents:
diff changeset
  3370
	] ifFalse:[
140
claus
parents: 138
diff changeset
  3371
	    super keyPress:key x:x y:y
135
claus
parents:
diff changeset
  3372
	]
claus
parents:
diff changeset
  3373
    ]
claus
parents:
diff changeset
  3374
!
claus
parents:
diff changeset
  3375
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3376
mapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3377
    "the view has been mapped (by some outside
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3378
     action - i.e. window manager de-iconified me)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3379
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3380
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3381
     the old code was:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3382
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3383
	realized := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3384
	shown := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3385
	...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3386
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3387
     this created a race condition, if the view was
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3388
     realized and shortly after unrealized - before the mapped event
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3389
     arrived. This lead to shown being set to true even thought the
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3390
     view was not. Boy - that was a bad one (hard to reproduce and hard to find).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3391
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3392
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3393
    realized ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3394
	shown := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3395
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3396
	 backed views will not get expose events - have
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3397
	 to force a redraw here to get things drawn into
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3398
	 backing store.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3399
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3400
	backed ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3401
	    self redraw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3402
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3403
	subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3404
	    subViews do:[:v |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3405
		v superViewMapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3406
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3407
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3408
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3409
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3410
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3411
reparented
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3412
    "the view has changed its parent by some outside
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3413
     action - i.e. window manager has added a frame.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3414
     nothing done here"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3415
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3416
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3417
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3418
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3419
saveAndTerminate
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3420
    "window manager wants me to save and go away; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3421
     - notice, that not all window managers are nice enough to 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3422
       send this event, but simply destroy the view instead.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3423
     Can be redefined in subclasses to do whatever is required
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3424
     to prepare for restart."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3425
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3426
    ^ self destroy
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3427
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3428
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3429
sizeChanged:how
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3430
    "tell subviews if I change size.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3431
     How is either #smaller, #larger or nil, and is used to control the order,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3432
     in which subviews are notified (possibly reducing redraw activity)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3433
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3434
    window notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3435
	"compute new transformation"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3436
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3437
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3438
	(how isNil "false" 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3439
	or:[how == #smaller]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3440
	    subViews do:[:view |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3441
		view superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3442
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3443
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3444
	    "doing it reverse speeds up resizing - usually subviews
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3445
	     are created from top-left to bottom-right; therefore
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3446
	     bottom-right views will be moved/resized first, then top-left ones;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3447
	     this avoids multiple redraws of subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3448
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3449
	    subViews reverseDo:[:view |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3450
		view superViewChangedSize
135
claus
parents:
diff changeset
  3451
	    ]
claus
parents:
diff changeset
  3452
	]
claus
parents:
diff changeset
  3453
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3454
    self changed:#sizeOfView with:how.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3455
    superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3456
	superView subViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3457
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3458
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3459
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3460
subViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3461
    "some subview has changed its size; we are not interrested
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3462
     in that here, but some geometry managers redefine this, to reorganize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3463
     components if that happens."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3464
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3465
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3466
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3467
    "Created: 22.9.1995 / 14:44:59 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3468
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3469
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3470
superViewChangedSize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3471
    "my superView has changed size; if I have relative
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3472
     origin/extent or blocks to evaluate, do it now .."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3473
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3474
    |oldWidth oldHeight oldTop oldLeft newExt newOrg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3475
     winSuper newWidth newHeight newLeft newTop
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3476
     superWidth superHeight superWinWidth superWinHeight
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3477
     r|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3478
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3479
    oldWidth := width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3480
    oldHeight := height.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3481
    oldTop := top.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3482
    oldLeft := left.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3483
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3484
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3485
     if this view has a viewPort, resize a la ST-80 V2.x
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3486
     this will vanish - dont use it.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3487
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3488
    viewport notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3489
	superView isNil ifTrue:[^ self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3490
	winSuper := superView window.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3491
	winSuper isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3492
	    "take pixel size as window"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3493
	    winSuper := 0@0 extent:(superView width@superView height)
135
claus
parents:
diff changeset
  3494
	].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3495
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3496
	superWidth := superView width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3497
	superHeight := superView height.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3498
	superWinWidth := winSuper width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3499
	superWinHeight := winSuper height.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3500
	newLeft := (viewport left - winSuper left) * superWidth // superWinWidth.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3501
	newTop := (viewport top - winSuper top) * superHeight // superWinHeight.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3502
	newWidth := superWidth * viewport width // superWinWidth.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3503
	newHeight := superHeight * viewport height // superWinHeight.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3504
	self pixelOrigin:(newLeft @ newTop).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3505
	self pixelExtent:(newWidth @ newHeight).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3506
	^ self
135
claus
parents:
diff changeset
  3507
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3508
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3509
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3510
     slowly migrating to use layoutObjects ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3511
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3512
    layout isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3513
	newOrg := self computeOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3514
	newExt := self computeExtent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3515
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3516
	r := (layout rectangleRelativeTo:(superView viewRectangle)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3517
			       preferred:(self preferredBounds)).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3518
	newOrg := r origin rounded.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3519
	newExt := r extent rounded.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3520
"/ newOrg printNL.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3521
"/ newExt printNL.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3522
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3523
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3524
    newOrg notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3525
	((newOrg x == oldLeft) and:[newOrg y == oldTop]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3526
	    newOrg := nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3527
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3528
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3529
    newExt notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3530
	((newExt x == width) and:[newExt y == height]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3531
	    newExt := nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3532
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3533
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3534
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3535
    newExt isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3536
	newOrg notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3537
	    self pixelOrigin:newOrg
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3538
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3539
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3540
	newOrg isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3541
	    self pixelExtent:newExt
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3542
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3543
	    self pixelOrigin:newOrg extent:newExt
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3544
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3545
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3546
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3547
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3548
superViewMapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3549
    "my superview was mapped (became visible)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3550
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3551
    realized ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3552
	shown := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3553
	subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3554
	    subViews do:[:v |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3555
		v superViewMapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3556
	    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3557
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3558
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3559
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3560
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3561
superViewUnmapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3562
    "my superView was unmapped"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3563
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3564
    self unmapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3565
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3566
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3567
terminate
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3568
    "window manager wants me to go away;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3569
     - notice, that not all window managers are nice enough to 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3570
       send this event, but simply destroy the view instead.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3571
     Can be redefined in subclasses to do whatever cleanup is 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3572
     required."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3573
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3574
    ^ self destroy
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3575
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3576
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3577
unmapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3578
    "the view has been unmapped 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3579
     (either by some outside action - i.e. window manager iconified me,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3580
     or due to unmapping of my parentView)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3581
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3582
    shown := false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3583
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3584
	subViews do:[:v |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3585
	    v superViewUnmapped
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3586
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3587
    ]
135
claus
parents:
diff changeset
  3588
!
claus
parents:
diff changeset
  3589
claus
parents:
diff changeset
  3590
visibilityChange:how
claus
parents:
diff changeset
  3591
    "the visibility of the view has changed (by some outside
claus
parents:
diff changeset
  3592
     action - i.e. window manager rearranged things).
claus
parents:
diff changeset
  3593
     Using this knowledge avoids useless redraw in obsucred views."
claus
parents:
diff changeset
  3594
claus
parents:
diff changeset
  3595
    how == #fullyObscured ifTrue:[
claus
parents:
diff changeset
  3596
	shown := false
claus
parents:
diff changeset
  3597
    ] ifFalse:[
claus
parents:
diff changeset
  3598
	shown := true.
claus
parents:
diff changeset
  3599
    ]
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3600
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3601
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3602
!SimpleView methodsFor:'informing others of changes'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3603
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3604
contentsChanged
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3605
    "this one is sent, whenever contents changes size -
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3606
     tell dependents about the change (i.e. scrollers)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3607
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3608
    self changed:#sizeOfContents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3609
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3610
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3611
originChanged:delta
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3612
    "this one is sent, after the origin of my contents has changed -
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3613
     tell dependents (i.e. scrollers) about this"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3614
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3615
    self changed:#originOfContents with:delta.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3616
"/   subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3617
"/        subViews do:[:aSubView |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3618
"/            aSubView pixelOrigin:((aSubView left @ aSubView top) - delta)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3619
"/        ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3620
"/    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3621
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3622
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3623
originWillChange
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3624
    "this one is sent, just before viewOrigin changes -
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3625
     gives subclasses a chance to catch scrolls easily
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3626
     (for example to hide cursor before scroll)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3627
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3628
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3629
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3630
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3631
!SimpleView methodsFor:'initialization'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3632
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3633
defaultControllerClass
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3634
    ^ nil "/ Controller
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3635
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3636
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3637
initEvents
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3638
    "will be sent by create - can be redefined by subclasses to enable
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3639
     view events"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3640
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3641
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3642
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3643
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3644
initStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3645
    "this method sets up all style dependent things"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3646
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3647
    self initStyleSheet.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3648
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3649
    borderWidth := DefaultBorderWidth.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3650
    borderWidth isNil ifTrue:[borderWidth := 1].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3651
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3652
    viewBackground := DefaultViewBackgroundColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3653
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3654
    DefaultLightColor notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3655
	lightColor := DefaultLightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3656
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3657
	device hasGreyscales ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3658
	    DefaultLightColor := lightColor := viewBackground lightened.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3659
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3660
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3661
	     this seems strange: on B&W screens, we create the light color 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3662
	     darker than normal viewBackground (White) -
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3663
	     to make the boundary of the view visible
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3664
	    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3665
	    lightColor := Color grey:50
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3666
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3667
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3668
    DefaultShadowColor notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3669
	shadowColor := DefaultShadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3670
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3671
	shadowColor := Black
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3672
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3673
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3674
    lightColor := lightColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3675
    shadowColor := shadowColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3676
    borderColor := DefaultBorderColor.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3677
    font := DefaultFont.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3678
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3679
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3680
initStyleSheet
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3681
    "this method gets the styleSheet"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3682
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3683
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3684
     when coming here the first time, we read the styleSheet
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3685
     and keep the values in fast class variables
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3686
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3687
    StyleSheet isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3688
	self class updateStyleCache
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3689
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3690
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3691
    styleSheet := StyleSheet.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3692
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3693
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3694
initialize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3695
    "initialize all state of the view - usually redefined in subclasses,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3696
     but always doing a 'super initialize'. Each class should setup its
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3697
     locals - and not forget the others.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3698
     View setup is separated into two parts, the general setup done here
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3699
     and the style specific setup in initStyle. Each view should be prepared
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3700
     for a stylechange by being sent another initStyle with a new style value.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3701
     (in this case, it should set all of its style-dependent things, but
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3702
      leave the state and contents as-is)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3703
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3704
    |ext myClass controllerClass|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3705
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3706
    super initialize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3707
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3708
    font := DefaultFont.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3709
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3710
    shown := hiddenOnRealize := realized := false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3711
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3712
    "fill in some defaults - some of them are usually redefined in subclasses
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3713
     initialize methods"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3714
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3715
    myClass := self class.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3716
    name := myClass name "asString" asLowercaseFirst.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3717
    ext := myClass defaultExtent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3718
    resources := myClass classResources.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3719
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3720
    level := margin := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3721
    margin := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3722
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3723
    self initStyle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3724
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3725
    left := top := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3726
    width := ext x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3727
    height := ext y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3728
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3729
    originChanged := extentChanged := false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3730
    bitGravity := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3731
    viewGravity := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3732
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3733
    controllerClass := self defaultControllerClass.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3734
    controllerClass notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3735
	controller := controllerClass new.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3736
	controller view:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3737
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3738
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3739
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3740
initializeMiddleButtonMenu
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3741
    "a place to initialize menu - this one is sent once when the view is
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3742
     first created; usually redefined in subclasses; default here is no menu.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3743
     Notice, that static middleButtonmenus are a historic thing in ST/X;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3744
     you may prefer to create the menu dynamically (i.e. the ST-80 way)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3745
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3746
    ^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3747
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3748
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3749
prepareForReinit
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3750
    super prepareForReinit.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3751
    windowGroup notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3752
	windowGroup reinitialize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3753
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3754
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3755
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3756
reinitStyle
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3757
    "this method is called for a style change"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3758
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3759
    |t|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3760
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3761
    self initStyle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3762
    drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3763
	"force a change"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3764
	t := borderWidth. borderWidth := nil. self borderWidth:t.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3765
	t := viewBackground. viewBackground := nil. self viewBackground:t.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3766
	self clear.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3767
	self redraw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3768
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3769
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3770
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3771
reinitialize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3772
    "this is called right snapIn"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3773
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3774
    |myController|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3775
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3776
    "if I have already been reinited - return"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3777
    drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3778
	^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3779
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3780
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3781
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3782
     superView must be there, first
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3783
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3784
    superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3785
	superView id isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3786
	    superView reinitialize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3787
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3788
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3789
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3790
    myController := controller.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3791
    controller := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3792
    self recreate.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3793
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3794
    "if I was mapped, do it again"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3795
    realized ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3796
	"only remap if I have a superview - otherwise, I might be
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3797
	 a hidden iconView or menu ..."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3798
	superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3799
"/            shown ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3800
		device mapView:self id:drawableId iconified:false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3801
			   atX:left y:top width:width height:height
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3802
"/            ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3803
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3804
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3805
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3806
    "restore controller"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3807
    controller := myController
135
claus
parents:
diff changeset
  3808
! !
claus
parents:
diff changeset
  3809
140
claus
parents: 138
diff changeset
  3810
!SimpleView methodsFor:'private'!
claus
parents: 138
diff changeset
  3811
claus
parents: 138
diff changeset
  3812
computeInnerClip
claus
parents: 138
diff changeset
  3813
    "compute, but do not set the inside clip-area"
claus
parents: 138
diff changeset
  3814
claus
parents: 138
diff changeset
  3815
    |m2 nX nY nW nH|
claus
parents: 138
diff changeset
  3816
claus
parents: 138
diff changeset
  3817
    (margin ~~ 0) ifTrue:[
claus
parents: 138
diff changeset
  3818
	m2 := margin + margin.
claus
parents: 138
diff changeset
  3819
	nX := nY := margin.
claus
parents: 138
diff changeset
  3820
	nW := width - m2.
claus
parents: 138
diff changeset
  3821
	nH := height - m2.
claus
parents: 138
diff changeset
  3822
	transformation notNil ifTrue:[
claus
parents: 138
diff changeset
  3823
	    nX := transformation applyInverseToX:nX.
claus
parents: 138
diff changeset
  3824
	    nY := transformation applyInverseToY:nY.
claus
parents: 138
diff changeset
  3825
	    nW := transformation applyInverseScaleX:nW.
claus
parents: 138
diff changeset
  3826
	    nH := transformation applyInverseScaleY:nH.
claus
parents: 138
diff changeset
  3827
	].
claus
parents: 138
diff changeset
  3828
	innerClipRect := Rectangle 
claus
parents: 138
diff changeset
  3829
				 left:nX 
claus
parents: 138
diff changeset
  3830
				 top:nY 
claus
parents: 138
diff changeset
  3831
				 width:nW 
claus
parents: 138
diff changeset
  3832
				 height:nH
claus
parents: 138
diff changeset
  3833
    ] ifFalse:[
claus
parents: 138
diff changeset
  3834
	"no clipping"
claus
parents: 138
diff changeset
  3835
	innerClipRect := nil
claus
parents: 138
diff changeset
  3836
    ]
claus
parents: 138
diff changeset
  3837
!
claus
parents: 138
diff changeset
  3838
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3839
cornerFromRelativeCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3840
    "compute & return pixel corner from relativeCorner"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3841
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3842
    ^ self cornerFromRelativeCorner:relativeCorner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3843
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3844
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3845
cornerFromRelativeCorner:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3846
    "compute & return pixel corner from a relativeCorner, aPoint"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3847
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3848
    |p r b bw|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3849
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3850
    p := self pointFromRelative:aPoint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3851
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3852
    bw := borderWidth.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3853
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3854
	bw == 0 ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3855
	    ^ p
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3856
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3857
	^ (p x - bw) @ (p y - bw)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3858
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3859
    r := (insets at:3) + bw.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3860
    b := (insets at:4) + bw.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3861
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3862
"/    r := b := bw.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3863
"/    rightInset notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3864
"/        r := rightInset + bw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3865
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3866
"/    bottomInset notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3867
"/        b := bottomInset + bw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3868
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3869
    ((r ~~ 0) or:[b ~~ 0]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3870
	^ (p x - r) @ (p y - b)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3871
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3872
    ^ p
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3873
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3874
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3875
dimensionFromViewport
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3876
    "define my origin/extend from viewport"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3877
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3878
    |relW relH relX relY winW winH org ext|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3879
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3880
    superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3881
	superView window isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3882
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3883
	    v := superView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3884
	    (v notNil and:[v window isNil]) whileTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3885
		v := v superview
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3886
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3887
	    v notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3888
		w := v window
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3889
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3890
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3891
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3892
	    winW := 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3893
	    winH := 1
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3894
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3895
	    winW := superView width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3896
	    winH := superView height.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3897
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3898
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3899
	    winW := superView window width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3900
	    winH := superView window height
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3901
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3902
	relW := (viewport width / winW) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3903
	relH := (viewport height / winH) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3904
	relX := (viewport left / winW) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3905
	relY := (viewport top / winH) asFloat.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3906
	"bad coding style ... misuse other method"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3907
	relativeOrigin := (relX @ relY).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3908
	org := self originFromRelativeOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3909
	relativeOrigin := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3910
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3911
	"bad coding style ...misuse other method"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3912
	relativeExtent := (relW @ relH).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3913
	ext := self extentFromRelativeExtent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3914
	relativeExtent := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3915
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3916
	self pixelOrigin:org extent:ext.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3917
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3918
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3919
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3920
extentFromRelativeExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3921
    "compute & return pixel extent from relativeExtent"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3922
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3923
    ^ self extentFromRelativeExtent:relativeExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3924
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3925
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3926
extentFromRelativeExtent:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3927
    "compute & return pixel extent from relativeExtent, aPoint"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3928
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3929
    |rel newX newY inRect bw2 i|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3930
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3931
    superView isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3932
	inRect := 0@0 extent:device extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3933
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3934
	inRect := superView viewRectangle.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3935
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3936
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3937
    bw2 := borderWidth * 2.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3938
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3939
    rel := aPoint x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3940
    rel isInteger ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3941
	newX := (rel * (inRect width + bw2)) asInteger + inRect left.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3942
	(borderWidth ~~ 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3943
	    newX := newX - borderWidth
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3944
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3945
    ] ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3946
	newX := rel
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3947
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3948
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3949
    rel := aPoint y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3950
    rel isInteger ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3951
	newY := (rel * (inRect height + bw2)) asInteger + inRect top.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3952
	(borderWidth ~~ 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3953
	    newY := newY - borderWidth
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3954
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3955
    ] ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3956
	newY := rel
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3957
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3958
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3959
    insets notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3960
	i := insets at:1.   "top"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3961
	(i  ~~ 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3962
	    newX := newX - i
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3963
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3964
	i := insets at:3.   "left"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3965
	(i  ~~ 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3966
	    newX := newX - i
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3967
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3968
	i := insets at:2.   "right"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3969
	(i ~~ 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3970
	    newY := newY - i
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3971
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3972
	i := insets at:4.   "bottom"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3973
	(i ~~ 0) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3974
	    newY := newY - i
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3975
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3976
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3977
    ^ newX @ newY
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3978
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3979
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3980
originFromRelativeOrigin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3981
    "compute & return pixel origin from relativeOrigin"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3982
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3983
    ^ self originFromRelativeOrigin:relativeOrigin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3984
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3985
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3986
originFromRelativeOrigin:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3987
    "compute & return pixel origin from relativeOrigin, aPoint"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3988
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3989
    |p l t|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3990
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3991
    p := self pointFromRelative:aPoint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3992
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3993
    insets isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3994
	^ p
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3995
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3996
    l := insets at:1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3997
    t := insets at:2.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3998
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  3999
"/  l := t := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4000
"/    leftInset notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4001
"/        l := leftInset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4002
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4003
"/    topInset notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4004
"/        t := topInset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4005
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4006
    ((l ~~ 0) or:[t ~~ 0]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4007
	^ (p x + l) @ (p y + t)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4008
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4009
    ^ p
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4010
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4011
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4012
pixelCorner:corner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4013
    "set the views corner in pixels"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4014
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4015
    |w h|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4016
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4017
    w := corner x - left + 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4018
    h := corner y - top + 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4019
    self pixelOrigin:(left @ top) extent:(w @ h)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4020
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4021
    "Modified: 31.8.1995 / 18:20:22 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4022
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4023
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4024
pixelExtent:extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4025
    "set the views extent in pixels"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4026
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4027
    self pixelOrigin:(left @ top) extent:extent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4028
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4029
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4030
pixelOrigin:origin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4031
    "set the views origin in pixels. For subviews. the origin is relative
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4032
     to the superviews top-left. For topViews, its the screen origin."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4033
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4034
    |newLeft newTop|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4035
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4036
    newLeft := origin x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4037
    newTop := origin y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4038
    ((newTop ~~ top) or:[newLeft ~~ left]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4039
	top := newTop.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4040
	left := newLeft.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4041
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4042
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4043
	 if the receiver is visible, or is a topView, perform the
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4044
	 operation right away - otherwise, simply remember that the
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4045
	 origin has changed - will tell the display once we get realized
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4046
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4047
"/        (shown 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4048
"/        or:[superView isNil and:[drawableId notNil]]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4049
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4050
	"/ no, have to do it if drawableId is there
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4051
	"/ (otherwise, we could not move unmapped views around ...
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4052
	"/
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4053
	drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4054
	    device moveWindow:drawableId x:left y:top
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4055
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4056
	    originChanged := true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4057
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4058
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4059
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4060
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4061
pixelOrigin:origin corner:corner
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4062
    "set the views origin and corner in pixels"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4063
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4064
    |w h|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4065
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4066
    w := corner x - origin x + 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4067
    h := corner y - origin y + 1.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4068
    self pixelOrigin:origin extent:(w @ h)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4069
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4070
    "Modified: 31.8.1995 / 18:24:16 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4071
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4072
140
claus
parents: 138
diff changeset
  4073
pixelOrigin:origin extent:extent
claus
parents: 138
diff changeset
  4074
    "set the views origin and extent in pixels"
claus
parents: 138
diff changeset
  4075
claus
parents: 138
diff changeset
  4076
    |newLeft newTop newWidth newHeight how 
claus
parents: 138
diff changeset
  4077
     mustRedrawBottomEdge mustRedrawRightEdge mustRepaintBottom
claus
parents: 138
diff changeset
  4078
     mustRepaintRight sameOrigin oldWidth oldHeight|
claus
parents: 138
diff changeset
  4079
claus
parents: 138
diff changeset
  4080
    newLeft := origin x.
claus
parents: 138
diff changeset
  4081
    newTop := origin y.
claus
parents: 138
diff changeset
  4082
    sameOrigin := ((newTop == top) and:[newLeft == left]).
claus
parents: 138
diff changeset
  4083
claus
parents: 138
diff changeset
  4084
    newWidth := extent x.
claus
parents: 138
diff changeset
  4085
    newHeight := extent y.
claus
parents: 138
diff changeset
  4086
claus
parents: 138
diff changeset
  4087
    "
claus
parents: 138
diff changeset
  4088
     X complains badly if you try to create/resize a view with
claus
parents: 138
diff changeset
  4089
     a dimension <= 0 ... (although I think that 0 maks sense ...)
claus
parents: 138
diff changeset
  4090
    "
claus
parents: 138
diff changeset
  4091
    newWidth < 1 ifTrue:[
claus
parents: 138
diff changeset
  4092
	newWidth := 1.
claus
parents: 138
diff changeset
  4093
    ].
claus
parents: 138
diff changeset
  4094
    newHeight < 1 ifTrue:[
claus
parents: 138
diff changeset
  4095
	newHeight := 1
claus
parents: 138
diff changeset
  4096
    ].
claus
parents: 138
diff changeset
  4097
claus
parents: 138
diff changeset
  4098
    ((newWidth == width) and:[newHeight == height]) ifTrue:[
claus
parents: 138
diff changeset
  4099
	sameOrigin ifTrue:[^ self].
claus
parents: 138
diff changeset
  4100
	^ self pixelOrigin:origin
claus
parents: 138
diff changeset
  4101
    ].
claus
parents: 138
diff changeset
  4102
    top := newTop.
claus
parents: 138
diff changeset
  4103
    left := newLeft.
claus
parents: 138
diff changeset
  4104
claus
parents: 138
diff changeset
  4105
"/    shown ifTrue:[                  "4-nov-94 actually correct,"
claus
parents: 138
diff changeset
  4106
    drawableId notNil ifTrue:[        "but theres a bug in menus when resized while hidden"
151
claus
parents: 145
diff changeset
  4107
	mustRedrawBottomEdge := (level ~~ 0) and:[newHeight < height].
claus
parents: 145
diff changeset
  4108
	mustRedrawRightEdge := (level ~~ 0) and:[newWidth < width].
claus
parents: 145
diff changeset
  4109
claus
parents: 145
diff changeset
  4110
	((newHeight <= height) and:[newWidth <= width]) ifTrue:[
claus
parents: 145
diff changeset
  4111
	    how := #smaller
claus
parents: 145
diff changeset
  4112
	].
claus
parents: 145
diff changeset
  4113
140
claus
parents: 138
diff changeset
  4114
	mustRepaintRight := false.
claus
parents: 138
diff changeset
  4115
	mustRepaintBottom := false.
claus
parents: 138
diff changeset
  4116
	(level ~~ 0) ifTrue:[
claus
parents: 138
diff changeset
  4117
	    "clear the old edges"
claus
parents: 138
diff changeset
  4118
claus
parents: 138
diff changeset
  4119
	    newWidth > width ifTrue:[
claus
parents: 138
diff changeset
  4120
		self clipRect:nil.
claus
parents: 138
diff changeset
  4121
		self paint:viewBackground.
claus
parents: 138
diff changeset
  4122
		self fillDeviceRectangleX:(width - margin)
claus
parents: 138
diff changeset
  4123
					y:0
claus
parents: 138
diff changeset
  4124
				    width:margin
claus
parents: 138
diff changeset
  4125
				   height:height.
claus
parents: 138
diff changeset
  4126
		mustRepaintRight := true.
claus
parents: 138
diff changeset
  4127
		oldWidth := width
claus
parents: 138
diff changeset
  4128
	    ].
claus
parents: 138
diff changeset
  4129
	    newHeight > height ifTrue:[
claus
parents: 138
diff changeset
  4130
		self clipRect:nil.
claus
parents: 138
diff changeset
  4131
		self paint:viewBackground.
claus
parents: 138
diff changeset
  4132
		self fillDeviceRectangleX:0
claus
parents: 138
diff changeset
  4133
					y:(height - margin)
claus
parents: 138
diff changeset
  4134
				    width:width
claus
parents: 138
diff changeset
  4135
				   height:margin.
claus
parents: 138
diff changeset
  4136
		mustRepaintBottom := true.
claus
parents: 138
diff changeset
  4137
		oldHeight := height
claus
parents: 138
diff changeset
  4138
	    ]
claus
parents: 138
diff changeset
  4139
	].
claus
parents: 138
diff changeset
  4140
claus
parents: 138
diff changeset
  4141
	width := newWidth.
claus
parents: 138
diff changeset
  4142
	height := newHeight.
claus
parents: 138
diff changeset
  4143
claus
parents: 138
diff changeset
  4144
	self setInnerClip.
claus
parents: 138
diff changeset
  4145
claus
parents: 138
diff changeset
  4146
	"if view becomes smaller, send sizeChanged first"
claus
parents: 138
diff changeset
  4147
	(how == #smaller) ifTrue:[
claus
parents: 138
diff changeset
  4148
	    self sizeChanged:how
claus
parents: 138
diff changeset
  4149
	].
claus
parents: 138
diff changeset
  4150
claus
parents: 138
diff changeset
  4151
	"have to tell X, when extent of view is changed"
claus
parents: 138
diff changeset
  4152
	sameOrigin ifTrue:[
claus
parents: 138
diff changeset
  4153
	    device resizeWindow:drawableId width:width height:height.
claus
parents: 138
diff changeset
  4154
	] ifFalse:[
claus
parents: 138
diff changeset
  4155
	    "claus: some xservers seem to do better when resizing
claus
parents: 138
diff changeset
  4156
	     first ...."
claus
parents: 138
diff changeset
  4157
" 
claus
parents: 138
diff changeset
  4158
	    (how == #smaller) ifTrue:[
claus
parents: 138
diff changeset
  4159
		device resizeWindow:drawableId width:width height:height.
claus
parents: 138
diff changeset
  4160
		device moveWindow:drawableId x:left y:top
claus
parents: 138
diff changeset
  4161
	    ] ifFalse:[
claus
parents: 138
diff changeset
  4162
		device moveResizeWindow:drawableId x:left y:top width:width height:height
claus
parents: 138
diff changeset
  4163
	    ].
claus
parents: 138
diff changeset
  4164
" 
claus
parents: 138
diff changeset
  4165
	    device moveResizeWindow:drawableId x:left y:top
claus
parents: 138
diff changeset
  4166
					   width:width height:height.
claus
parents: 138
diff changeset
  4167
" "
claus
parents: 138
diff changeset
  4168
	].
claus
parents: 138
diff changeset
  4169
claus
parents: 138
diff changeset
  4170
	"if view becomes bigger, send sizeChanged after"
claus
parents: 138
diff changeset
  4171
	(how ~~ #smaller) ifTrue:[
claus
parents: 138
diff changeset
  4172
	    self sizeChanged:how
claus
parents: 138
diff changeset
  4173
	].
claus
parents: 138
diff changeset
  4174
claus
parents: 138
diff changeset
  4175
	(mustRedrawBottomEdge or:[mustRedrawRightEdge]) ifTrue:[
claus
parents: 138
diff changeset
  4176
	    self clipRect:nil.
claus
parents: 138
diff changeset
  4177
	    mustRedrawBottomEdge ifTrue:[
claus
parents: 138
diff changeset
  4178
		self drawBottomEdge
claus
parents: 138
diff changeset
  4179
	    ].
claus
parents: 138
diff changeset
  4180
	    mustRedrawRightEdge ifTrue:[
claus
parents: 138
diff changeset
  4181
		self drawRightEdge
claus
parents: 138
diff changeset
  4182
	    ].
claus
parents: 138
diff changeset
  4183
	    self clipRect:innerClipRect
claus
parents: 138
diff changeset
  4184
	].
claus
parents: 138
diff changeset
  4185
claus
parents: 138
diff changeset
  4186
	mustRepaintRight ifTrue:[
claus
parents: 138
diff changeset
  4187
	    self redrawDeviceX:(oldWidth - margin)
claus
parents: 138
diff changeset
  4188
			     y:0
claus
parents: 138
diff changeset
  4189
			 width:margin
claus
parents: 138
diff changeset
  4190
			height:height.
claus
parents: 138
diff changeset
  4191
	].
claus
parents: 138
diff changeset
  4192
	mustRepaintBottom ifTrue:[
claus
parents: 138
diff changeset
  4193
	    self redrawDeviceX:0
claus
parents: 138
diff changeset
  4194
			     y:(oldHeight - margin)
claus
parents: 138
diff changeset
  4195
			 width:width
claus
parents: 138
diff changeset
  4196
			height:margin.
claus
parents: 138
diff changeset
  4197
	].
claus
parents: 138
diff changeset
  4198
    ] ifFalse:[
claus
parents: 138
diff changeset
  4199
	"otherwise memorize the need for a sizeChanged message"
claus
parents: 138
diff changeset
  4200
claus
parents: 138
diff changeset
  4201
	width := newWidth.
claus
parents: 138
diff changeset
  4202
	height := newHeight.
claus
parents: 138
diff changeset
  4203
	sameOrigin ifFalse:[
claus
parents: 138
diff changeset
  4204
	    originChanged := true.
claus
parents: 138
diff changeset
  4205
	].
claus
parents: 138
diff changeset
  4206
	extentChanged := true
claus
parents: 138
diff changeset
  4207
    ]
claus
parents: 138
diff changeset
  4208
!
claus
parents: 138
diff changeset
  4209
claus
parents: 138
diff changeset
  4210
pointFromRelative:p
claus
parents: 138
diff changeset
  4211
    "compute absolute coordinate from p"
claus
parents: 138
diff changeset
  4212
claus
parents: 138
diff changeset
  4213
    |newX newY rel inRect bw superWidth superHeight superLeft superTop |
claus
parents: 138
diff changeset
  4214
claus
parents: 138
diff changeset
  4215
    bw := borderWidth.
claus
parents: 138
diff changeset
  4216
claus
parents: 138
diff changeset
  4217
    superView isNil ifTrue:[
claus
parents: 138
diff changeset
  4218
	superWidth := device width + bw.      
claus
parents: 138
diff changeset
  4219
	superHeight := device height + bw.
claus
parents: 138
diff changeset
  4220
	superLeft := superTop := 0.
claus
parents: 138
diff changeset
  4221
    ] ifFalse:[
claus
parents: 138
diff changeset
  4222
	inRect := superView viewRectangle.
claus
parents: 138
diff changeset
  4223
	superWidth := inRect width.
claus
parents: 138
diff changeset
  4224
	superHeight := inRect height.
claus
parents: 138
diff changeset
  4225
	superLeft := inRect left.
claus
parents: 138
diff changeset
  4226
	superTop := inRect top.
claus
parents: 138
diff changeset
  4227
    ].
claus
parents: 138
diff changeset
  4228
claus
parents: 138
diff changeset
  4229
    rel := p x.
claus
parents: 138
diff changeset
  4230
    rel isInteger ifTrue:[
claus
parents: 138
diff changeset
  4231
	newX := rel
claus
parents: 138
diff changeset
  4232
    ] ifFalse:[
claus
parents: 138
diff changeset
  4233
	newX := (rel * superWidth) asInteger + superLeft.
claus
parents: 138
diff changeset
  4234
	(bw ~~ 0) ifTrue:[
claus
parents: 138
diff changeset
  4235
	    rel ~= 1.0 ifTrue:[
claus
parents: 138
diff changeset
  4236
		newX := newX - bw
claus
parents: 138
diff changeset
  4237
	    ]
claus
parents: 138
diff changeset
  4238
	]
claus
parents: 138
diff changeset
  4239
    ].
claus
parents: 138
diff changeset
  4240
claus
parents: 138
diff changeset
  4241
    rel := p y.
claus
parents: 138
diff changeset
  4242
    rel isInteger ifTrue:[
claus
parents: 138
diff changeset
  4243
	newY := rel
claus
parents: 138
diff changeset
  4244
    ] ifFalse:[
claus
parents: 138
diff changeset
  4245
	newY := (rel * superHeight) asInteger + superTop.
claus
parents: 138
diff changeset
  4246
	(bw ~~ 0) ifTrue:[
claus
parents: 138
diff changeset
  4247
	    rel ~= 1.0 ifTrue:[
claus
parents: 138
diff changeset
  4248
		newY := newY - bw
claus
parents: 138
diff changeset
  4249
	    ]
claus
parents: 138
diff changeset
  4250
	]
claus
parents: 138
diff changeset
  4251
    ].
claus
parents: 138
diff changeset
  4252
    ^ newX @ newY
claus
parents: 138
diff changeset
  4253
!
claus
parents: 138
diff changeset
  4254
claus
parents: 138
diff changeset
  4255
setBorderColor
claus
parents: 138
diff changeset
  4256
    "set my borderColor"
claus
parents: 138
diff changeset
  4257
claus
parents: 138
diff changeset
  4258
    |id dither|
claus
parents: 138
diff changeset
  4259
claus
parents: 138
diff changeset
  4260
    drawableId notNil ifTrue:[
claus
parents: 138
diff changeset
  4261
	borderColor := borderColor on:device.
claus
parents: 138
diff changeset
  4262
	id := borderColor colorId.
claus
parents: 138
diff changeset
  4263
	id notNil ifTrue:[
claus
parents: 138
diff changeset
  4264
	    device setWindowBorderColor:id in:drawableId
claus
parents: 138
diff changeset
  4265
	] ifFalse:[
claus
parents: 138
diff changeset
  4266
	    dither := borderColor ditherForm.
claus
parents: 138
diff changeset
  4267
	    dither notNil ifTrue:[
claus
parents: 138
diff changeset
  4268
		device setWindowBorderPixmap:(dither id) in:drawableId
claus
parents: 138
diff changeset
  4269
	    ] ifFalse:[
145
claus
parents: 144
diff changeset
  4270
		'VIEW: bad borderColor' errorPrintNL
135
claus
parents:
diff changeset
  4271
	    ]
claus
parents:
diff changeset
  4272
	]
claus
parents:
diff changeset
  4273
    ]
claus
parents:
diff changeset
  4274
!
claus
parents:
diff changeset
  4275
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4276
setInnerClip
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4277
    "compute, and set the inside clip-area"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4278
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4279
    self computeInnerClip.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4280
    self clipRect:innerClipRect
140
claus
parents: 138
diff changeset
  4281
! !
claus
parents: 138
diff changeset
  4282
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4283
!SimpleView methodsFor:'queries'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4284
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4285
buttonMotionEventPending
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4286
    "return true, if a button motion event is pending.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4287
     Normally, you dont want to use this, since no polling is needed
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4288
     (not even for mouse-tracking).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4289
     Dont use it, since it does not honor the windowGroup, but
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4290
     goes directly to the device instead.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4291
     Actually, its a historical leftover"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4292
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4293
    windowGroup notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4294
	^ windowGroup sensor hasButtonMotionEventsFor:self
140
claus
parents: 138
diff changeset
  4295
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4296
    ^ super buttonMotionEventPending
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4297
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4298
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4299
canHandle:aKey
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4300
    "return true, if I like to handle the key (from a keyPress event).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4301
     OBSOLETE: do not use & depend on this method, it is a historic
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4302
     leftOver and will be removed. Use the delegation mechanism for this."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4303
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4304
    ^ false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4305
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4306
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4307
canHandle:aKey from:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4308
    "return true, if I like to handle the key (from a keyPress event)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4309
     in aView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4310
     OBSOLETE: do not use & depend on this method, it is a historic
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4311
     leftOver and will be removed. Use the delegation mechanism for this."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4312
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4313
    ^ self canHandle:aKey
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4314
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4315
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4316
delegatesTo:someone
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4317
    "return true, if I delegate events to someone"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4318
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4319
    delegate isNil ifTrue:[^ false].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4320
    ^ delegate delegatesTo:someone
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4321
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4322
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4323
hasFocus
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4324
    "return true, if the receiver has the keyboard focus
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4325
     (either via the focusView mechanism in the windowGroup,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4326
      or via delegation)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4327
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4328
    |focusView delegate|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4329
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4330
    windowGroup isNil ifTrue:[^ false].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4331
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4332
    (focusView := windowGroup focusView) == self ifTrue:[^ true].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4333
    focusView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4334
	"mhmh - is there a delegation to me ?"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4335
	(delegate := focusView delegate) notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4336
	    delegate == self ifTrue:[^ true].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4337
	    ^ delegate delegatesTo:self
135
claus
parents:
diff changeset
  4338
	]
claus
parents:
diff changeset
  4339
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4340
    ^ false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4341
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4342
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4343
isSubViewOf:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4344
    "return true, if I am a subview of aView"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4345
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4346
    aView == self isNil ifTrue:[^ true].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4347
    superView isNil ifTrue:[^ false].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4348
    superView == aView ifTrue:[^ true].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4349
    ^ superView isSubViewOf:aView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4350
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4351
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4352
isView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4353
    "return true, if the receiver is some kind of view;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4354
     true is returned here."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4355
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4356
    ^ true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4357
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4358
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4359
preferredBounds
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4360
    "ST-80 compatibility."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4361
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4362
    ^ 0@0 corner:self preferredExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4363
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4364
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4365
preferredExtent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4366
    "return my preferred extent - this is the minimum size I would like to have.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4367
     The default here is the actual extent, the receiver currently has."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4368
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4369
    "mhmh - if I have components, collect their
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4370
     preferred bounds ..."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4371
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4372
    |maxX maxY|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4373
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4374
    subViews isNil ifTrue:[^ self extent].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4375
"/    ^ self extent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4376
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4377
    maxX := maxY := 0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4378
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4379
	subViews do:[:aSubView |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4380
	    |org corn|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4381
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4382
	    org := aSubView computeOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4383
	    corn := org + aSubView preferredExtent.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4384
	    maxX := maxX max:corn x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4385
	    maxY := maxY max:corn y.
140
claus
parents: 138
diff changeset
  4386
	]
claus
parents: 138
diff changeset
  4387
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4388
    ^ maxX @ maxY.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4389
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4390
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4391
sizeFixed
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4392
    "return true, if this vew wants its size to remain unchanged.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4393
     Used by panels, to check if their components want to keep their size."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4394
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4395
    ^ false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4396
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4397
    "Created: 17.9.1995 / 20:29:20 / claus"
140
claus
parents: 138
diff changeset
  4398
! !
claus
parents: 138
diff changeset
  4399
claus
parents: 138
diff changeset
  4400
!SimpleView methodsFor:'realization'!
claus
parents: 138
diff changeset
  4401
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4402
create
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4403
    "create (i.e. tell my device about me) if not already created.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4404
     This does not make the view visible (needs a #map for that)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4405
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4406
    drawableId isNil ifTrue:[
151
claus
parents: 145
diff changeset
  4407
	"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4408
	 make certain that superview is created also
151
claus
parents: 145
diff changeset
  4409
	"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4410
	superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4411
"/            superView id isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4412
		superView create.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4413
"/            ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4414
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4415
"/            "and put my controller into the superviews controller list"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4416
"/            controller notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4417
"/                superView controller notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4418
"/                    controller manager:(superView controller manager)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4419
"/                ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4420
"/            ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4421
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4422
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4423
	cursor := cursor on:device.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4424
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4425
	self physicalCreate.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4426
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4427
	viewBackground notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4428
	   self setViewBackground
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4429
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4430
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4431
	self initializeMiddleButtonMenu.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4432
	self initEvents.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4433
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4434
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4435
	 this is the first create,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4436
	 force sizechange messages to be sent to the view
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4437
	"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4438
	extentChanged := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4439
	originChanged := true
151
claus
parents: 145
diff changeset
  4440
    ]
claus
parents: 145
diff changeset
  4441
!
claus
parents: 145
diff changeset
  4442
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4443
createWithAllSubViews
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4444
    "create, then create all subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4445
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4446
    drawableId isNil ifTrue:[self create].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4447
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4448
	subViews do:[:subView | subView createWithAllSubViews]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4449
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4450
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4451
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4452
destroy
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4453
    "unrealize & destroy - make me invisible, destroy subviews then
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4454
     make me unknown to the device"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4455
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4456
    |subs|
140
claus
parents: 138
diff changeset
  4457
claus
parents: 138
diff changeset
  4458
    realized ifTrue:[
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4459
	self unrealize.            
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4460
	"make it go away immediately
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4461
	 - also, this hides the subview killing"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4462
"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4463
	device synchronizeOutput. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4464
"
151
claus
parents: 145
diff changeset
  4465
    ].
claus
parents: 145
diff changeset
  4466
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4467
"/    controller notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4468
"/      controller release.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4469
"/      controller := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4470
"/    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4471
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4472
    subs := subViews.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4473
    subs notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4474
	"stupid: destroy removes itself from the subview list
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4475
	 - therefore we have to loop over a copy here"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4476
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4477
	subViews := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4478
	subs do:[:aView |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4479
	    aView notNil ifTrue:[aView destroy]             
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4480
	]
140
claus
parents: 138
diff changeset
  4481
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4482
    superView notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4483
	superView removeSubView:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4484
	superView := nil
140
claus
parents: 138
diff changeset
  4485
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4486
    super destroy.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4487
312
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  4488
    superView isNil ifTrue:[
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  4489
	device flush
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  4490
    ].
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  4491
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4492
    controller notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4493
	controller release.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4494
	controller := nil.
140
claus
parents: 138
diff changeset
  4495
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4496
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4497
    windowGroup notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4498
	windowGroup removeView:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4499
	windowGroup := nil
140
claus
parents: 138
diff changeset
  4500
    ].
claus
parents: 138
diff changeset
  4501
!
claus
parents: 138
diff changeset
  4502
claus
parents: 138
diff changeset
  4503
fixSize
claus
parents: 138
diff changeset
  4504
    "This is called right before the view is made visible.
claus
parents: 138
diff changeset
  4505
     Adjust the size of the view according to either relative/abs or
claus
parents: 138
diff changeset
  4506
     block extent; also set origin. Also, subclasses may redefine this
claus
parents: 138
diff changeset
  4507
     method to adjust the size based on some extent (for example, PopUpMenus
claus
parents: 138
diff changeset
  4508
     do so to take care of changed number of menu entries)."
claus
parents: 138
diff changeset
  4509
151
claus
parents: 145
diff changeset
  4510
    |org ext r|
claus
parents: 145
diff changeset
  4511
claus
parents: 145
diff changeset
  4512
    "please: no longer use window/viewport - they will vanish"
140
claus
parents: 138
diff changeset
  4513
    window notNil ifTrue:[
claus
parents: 138
diff changeset
  4514
	^ self superViewChangedSize
claus
parents: 138
diff changeset
  4515
    ].
claus
parents: 138
diff changeset
  4516
151
claus
parents: 145
diff changeset
  4517
    "
claus
parents: 145
diff changeset
  4518
     slowly migrating to use layoutObjects ...
claus
parents: 145
diff changeset
  4519
    "
claus
parents: 145
diff changeset
  4520
    layout notNil ifTrue:[
claus
parents: 145
diff changeset
  4521
	(originChanged or:[extentChanged or:[cornerChanged]]) ifTrue:[
claus
parents: 145
diff changeset
  4522
	    r := (layout rectangleRelativeTo:(superView viewRectangle)
claus
parents: 145
diff changeset
  4523
				   preferred:(self preferredBounds)).
claus
parents: 145
diff changeset
  4524
	    org := r origin rounded.
claus
parents: 145
diff changeset
  4525
	    ext := r extent rounded.
claus
parents: 145
diff changeset
  4526
	    self pixelOrigin:org extent:ext.
claus
parents: 145
diff changeset
  4527
	].
claus
parents: 145
diff changeset
  4528
	^ self.
claus
parents: 145
diff changeset
  4529
    ].
claus
parents: 145
diff changeset
  4530
140
claus
parents: 138
diff changeset
  4531
    "if the extent is not the one we created the window with ..."
claus
parents: 138
diff changeset
  4532
    extentChanged ifTrue:[
claus
parents: 138
diff changeset
  4533
	self sizeChanged:nil.
claus
parents: 138
diff changeset
  4534
	extentChanged := false
claus
parents: 138
diff changeset
  4535
    ].
claus
parents: 138
diff changeset
  4536
claus
parents: 138
diff changeset
  4537
    originChanged ifTrue:[
claus
parents: 138
diff changeset
  4538
"/        org := self computeOrigin.
claus
parents: 138
diff changeset
  4539
"/        self pixelOrigin:org.    
claus
parents: 138
diff changeset
  4540
	originRule notNil ifTrue:[
claus
parents: 138
diff changeset
  4541
	    self pixelOrigin:self computeOrigin
claus
parents: 138
diff changeset
  4542
	] ifFalse:[
claus
parents: 138
diff changeset
  4543
	    relativeOrigin notNil ifTrue:[
claus
parents: 138
diff changeset
  4544
		self originFromRelativeOrigin:relativeOrigin
claus
parents: 138
diff changeset
  4545
	    ] ifFalse:[
151
claus
parents: 145
diff changeset
  4546
		shown ifTrue:[
claus
parents: 145
diff changeset
  4547
		    device moveWindow:drawableId x:left y:top.
claus
parents: 145
diff changeset
  4548
		] ifFalse:[
claus
parents: 145
diff changeset
  4549
		    self pixelOrigin:left@top
claus
parents: 145
diff changeset
  4550
		].
140
claus
parents: 138
diff changeset
  4551
	    ].
claus
parents: 138
diff changeset
  4552
	].
claus
parents: 138
diff changeset
  4553
	originChanged := false
claus
parents: 138
diff changeset
  4554
    ]
claus
parents: 138
diff changeset
  4555
!
claus
parents: 138
diff changeset
  4556
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4557
map
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4558
    "make the view visible on the screen"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4559
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4560
    realized ifFalse:[
140
claus
parents: 138
diff changeset
  4561
	"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4562
	 now, make the view visible
140
claus
parents: 138
diff changeset
  4563
	"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4564
	device mapWindow:drawableId.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4565
	realized := true.
140
claus
parents: 138
diff changeset
  4566
    ]
claus
parents: 138
diff changeset
  4567
!
claus
parents: 138
diff changeset
  4568
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4569
physicalCreate
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4570
    "common code for create & recreate: 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4571
     physically create (but do not map) the view on the device."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4572
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4573
    "associate colors to device"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4574
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4575
    drawableId := device 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4576
		      createWindowFor:self 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4577
			  origin:(left @ top)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4578
			  extent:(width @ height)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4579
			  minExtent:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4580
			  maxExtent:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4581
			  borderWidth:borderWidth
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4582
			  subViewOf:superView
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4583
			  onTop:(self isPopUpView)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4584
			  inputOnly:(self inputOnly)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4585
			  label:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4586
			  cursor:cursor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4587
			  icon:nil
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4588
			  iconView:nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4589
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4590
    Lobby registerChange:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4591
    extentChanged := false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4592
    originChanged := false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4593
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4594
    (borderColor notNil and:[borderColor ~~ Black]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4595
"/        borderColor := borderColor on:device.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4596
	self setBorderColor
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4597
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4598
    (viewGravity notNil "and:[viewGravity ~~ #NorthWest]") ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4599
	device setWindowGravity:viewGravity in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4600
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4601
    (bitGravity notNil "and:[bitGravity ~~ #NorthWest]") ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4602
	device setBitGravity:bitGravity in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4603
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4604
    borderShape notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4605
	device setWindowBorderShape:(borderShape id) in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4606
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4607
    viewShape notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4608
	device setWindowShape:(viewShape id) in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4609
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4610
    (backed notNil and:[backed ~~ false]) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4611
	device setBackingStore:backed in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4612
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4613
    saveUnder ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4614
	device setSaveUnder:true in:drawableId
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4615
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4616
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4617
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4618
realize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4619
    "realize - make visible;
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4620
     realizing is done very late (after layout is fixed) to avoid
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4621
     visible rearranging of windows on the screen"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4622
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4623
    self realizeLeavingGroup:false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4624
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4625
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4626
realizeAllSubViews
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4627
    "realize all my subviews"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4628
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4629
    subViews notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4630
	subViews do:[:subView |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4631
	    subView realize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4632
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4633
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4634
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4635
    "Modified: 5.9.1995 / 23:30:47 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4636
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4637
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4638
realizeInGroup
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4639
    "special realize - leave windowgroup as is; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4640
     This allows a view to be realized in any windowgroup; 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4641
     for special applications, like the kill button in the Filebrowser which has
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4642
     another windowGroup as its superview and is handled as a separate process."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4643
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4644
    self realizeLeavingGroup:true
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4645
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4646
140
claus
parents: 138
diff changeset
  4647
realizeLeavingGroup:leaveGroupAsIs 
151
claus
parents: 145
diff changeset
  4648
    "common helper for realize and realizeInGroup.
claus
parents: 145
diff changeset
  4649
     Create the view, if the argument is not true, assign my windowGroup,
claus
parents: 145
diff changeset
  4650
     if hiddenOnRealize is not true, map it."
140
claus
parents: 138
diff changeset
  4651
claus
parents: 138
diff changeset
  4652
    |superGroup groupChange|
claus
parents: 138
diff changeset
  4653
claus
parents: 138
diff changeset
  4654
    drawableId isNil ifTrue:[
claus
parents: 138
diff changeset
  4655
	self create.
claus
parents: 138
diff changeset
  4656
    ].
claus
parents: 138
diff changeset
  4657
claus
parents: 138
diff changeset
  4658
    leaveGroupAsIs ifFalse:[
claus
parents: 138
diff changeset
  4659
	"
claus
parents: 138
diff changeset
  4660
	 put myself into superviews windowgroup if there is a superview
claus
parents: 138
diff changeset
  4661
	"
claus
parents: 138
diff changeset
  4662
	groupChange := false.
claus
parents: 138
diff changeset
  4663
	superView notNil ifTrue:[
claus
parents: 138
diff changeset
  4664
	    superGroup := superView windowGroup.
claus
parents: 138
diff changeset
  4665
	    (windowGroup notNil and:[superGroup ~~ windowGroup]) ifTrue:[
claus
parents: 138
diff changeset
  4666
		"
claus
parents: 138
diff changeset
  4667
		 mhmh - seems that the windowgroup has changed ....
claus
parents: 138
diff changeset
  4668
		"
145
claus
parents: 144
diff changeset
  4669
"/                'oops - wgroup change on realize' printNL.
140
claus
parents: 138
diff changeset
  4670
		windowGroup removeView:self.
claus
parents: 138
diff changeset
  4671
		windowGroup := nil
claus
parents: 138
diff changeset
  4672
	    ].
claus
parents: 138
diff changeset
  4673
	    superGroup ~~ windowGroup ifTrue:[
claus
parents: 138
diff changeset
  4674
		groupChange := true.
claus
parents: 138
diff changeset
  4675
		windowGroup := superGroup.
claus
parents: 138
diff changeset
  4676
		windowGroup notNil ifTrue:[
claus
parents: 138
diff changeset
  4677
		    windowGroup addView:self.
claus
parents: 138
diff changeset
  4678
		]
claus
parents: 138
diff changeset
  4679
	    ]
claus
parents: 138
diff changeset
  4680
	].
claus
parents: 138
diff changeset
  4681
    ].
claus
parents: 138
diff changeset
  4682
151
claus
parents: 145
diff changeset
  4683
    hiddenOnRealize ifFalse:[
175
claus
parents: 173
diff changeset
  4684
	(originChanged or:[extentChanged]) ifTrue:[
claus
parents: 173
diff changeset
  4685
	    self fixSize.
claus
parents: 173
diff changeset
  4686
	    self sizeChanged:nil.   "/ new 29-aug-1995
claus
parents: 173
diff changeset
  4687
	].
140
claus
parents: 138
diff changeset
  4688
claus
parents: 138
diff changeset
  4689
	(realized not or:[groupChange]) ifTrue:[
claus
parents: 138
diff changeset
  4690
	    subViews notNil ifTrue:[
180
claus
parents: 176
diff changeset
  4691
		self realizeAllSubViews.
140
claus
parents: 138
diff changeset
  4692
	    ].
claus
parents: 138
diff changeset
  4693
	].
claus
parents: 138
diff changeset
  4694
	self setInnerClip.
claus
parents: 138
diff changeset
  4695
claus
parents: 138
diff changeset
  4696
	realized ifFalse:[
claus
parents: 138
diff changeset
  4697
	    "
claus
parents: 138
diff changeset
  4698
	     now, make the view visible
claus
parents: 138
diff changeset
  4699
	    "
151
claus
parents: 145
diff changeset
  4700
	    self map
140
claus
parents: 138
diff changeset
  4701
	]
claus
parents: 138
diff changeset
  4702
    ].
claus
parents: 138
diff changeset
  4703
claus
parents: 138
diff changeset
  4704
    controller notNil ifTrue:[
claus
parents: 138
diff changeset
  4705
	controller startUp
claus
parents: 138
diff changeset
  4706
    ]
claus
parents: 138
diff changeset
  4707
!
claus
parents: 138
diff changeset
  4708
claus
parents: 138
diff changeset
  4709
recreate
claus
parents: 138
diff changeset
  4710
    "recreate (i.e. tell X about me) after a snapin"
claus
parents: 138
diff changeset
  4711
claus
parents: 138
diff changeset
  4712
    drawableId isNil ifTrue:[
claus
parents: 138
diff changeset
  4713
	super recreate.
claus
parents: 138
diff changeset
  4714
	self physicalCreate.
claus
parents: 138
diff changeset
  4715
claus
parents: 138
diff changeset
  4716
	viewBackground notNil ifTrue:[
claus
parents: 138
diff changeset
  4717
	    self setViewBackground 
claus
parents: 138
diff changeset
  4718
	].
claus
parents: 138
diff changeset
  4719
claus
parents: 138
diff changeset
  4720
	"
claus
parents: 138
diff changeset
  4721
	 XXX has to be changed: eventmasks are device specific -
claus
parents: 138
diff changeset
  4722
	 XXX will not allow restart on another Workstation-type.
claus
parents: 138
diff changeset
  4723
	 XXX event masks must become symbolic
claus
parents: 138
diff changeset
  4724
	"
claus
parents: 138
diff changeset
  4725
	device setEventMask:eventMask in:drawableId
claus
parents: 138
diff changeset
  4726
    ]
claus
parents: 138
diff changeset
  4727
!
claus
parents: 138
diff changeset
  4728
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4729
rerealize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4730
    "rerealize at old position"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4731
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4732
    drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4733
	realized := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4734
	device mapView:self id:drawableId iconified:false
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4735
		   atX:left y:top width:width height:height
140
claus
parents: 138
diff changeset
  4736
    ]
claus
parents: 138
diff changeset
  4737
!
claus
parents: 138
diff changeset
  4738
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4739
rerealizeInGroup:aWindowGroup
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4740
    "rerealize at old position in (a possibly different) windowGroup."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4741
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4742
    drawableId isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4743
	self create
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4744
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4745
    drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4746
	aWindowGroup ~~ windowGroup ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4747
	    windowGroup notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4748
		windowGroup removeView:self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4749
	    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4750
	    windowGroup := aWindowGroup.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4751
	    aWindowGroup addTopView:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4752
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4753
	self rerealize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4754
    ]
140
claus
parents: 138
diff changeset
  4755
!
claus
parents: 138
diff changeset
  4756
claus
parents: 138
diff changeset
  4757
rerealizeWithAllSubViews
claus
parents: 138
diff changeset
  4758
    "rerealize myself with all subviews"
claus
parents: 138
diff changeset
  4759
claus
parents: 138
diff changeset
  4760
    drawableId notNil ifTrue:[
claus
parents: 138
diff changeset
  4761
	realized := true.
claus
parents: 138
diff changeset
  4762
	subViews notNil ifTrue:[
180
claus
parents: 176
diff changeset
  4763
	    self realizeAllSubViews.
140
claus
parents: 138
diff changeset
  4764
	].
claus
parents: 138
diff changeset
  4765
	device mapView:self id:drawableId iconified:false
claus
parents: 138
diff changeset
  4766
		   atX:left y:top width:width height:height
claus
parents: 138
diff changeset
  4767
    ]
180
claus
parents: 176
diff changeset
  4768
!
claus
parents: 176
diff changeset
  4769
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4770
resize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4771
    "resize myself to make everything fit into me.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4772
     Nothing special done here, but redefined in some subclasses"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4773
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4774
    self extent:(self preferredExtent)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4775
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4776
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4777
unmap
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4778
    "hide me - the view stays created, and can be mapped again later."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4779
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4780
    realized ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4781
	drawableId notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4782
	    device unmapWindow:drawableId
151
claus
parents: 145
diff changeset
  4783
	].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4784
	realized := shown := false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4785
    ].
190
claus
parents: 189
diff changeset
  4786
claus
parents: 189
diff changeset
  4787
    "
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4788
     |top sub|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4789
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4790
     top := StandardSystemView new.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4791
     top extent:200@200.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4792
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4793
     sub := View
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4794
		origin:0.2@0.2
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4795
		corner:0.8@0.8
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4796
		in:top.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4797
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4798
     sub viewBackground:Color red.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4799
     sub hiddenOnRealize:true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4800
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4801
     top open.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4802
     (Delay forSeconds:5) wait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4803
     sub map.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4804
     (Delay forSeconds:3) wait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4805
     sub unmap.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4806
     sub viewBackground:(Color green).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4807
     (Delay forSeconds:3) wait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4808
     sub map.
151
claus
parents: 145
diff changeset
  4809
    "
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4810
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4811
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4812
unrealize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4813
    "alias for unmap, for historic reasons"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4814
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4815
    self unmap.
151
claus
parents: 145
diff changeset
  4816
! !
claus
parents: 145
diff changeset
  4817
claus
parents: 145
diff changeset
  4818
!SimpleView methodsFor:'redrawing'!
claus
parents: 145
diff changeset
  4819
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4820
redraw
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4821
    "redraw myself
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4822
     cannot do much here - has to be redefined in subclasses"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4823
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4824
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4825
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4826
redrawDeviceX:x y:y width:w height:h
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4827
    "have to redraw part of the view.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4828
     The coordinates are in device space - if there is a transformation,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4829
     must inverse-transform back to logical coordinates. (since the view thinks
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4830
     in its coordinate space)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4831
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4832
    |lx ly lw lh|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4833
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4834
    lx := x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4835
    ly := y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4836
    lw := w.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4837
    lh := h.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4838
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4839
    transformation notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4840
	lx := transformation applyInverseToX:lx.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4841
	ly := transformation applyInverseToY:ly.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4842
	lw := transformation applyInverseScaleX:lw.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4843
	lh := transformation applyInverseScaleY:lh.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4844
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4845
    self redrawX:lx y:ly width:lw height:lh
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4846
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4847
151
claus
parents: 145
diff changeset
  4848
redrawX:x y:y width:w height:h
claus
parents: 145
diff changeset
  4849
    "have to redraw part of myself, given logical coordinates (if trans is nonNil)
claus
parents: 145
diff changeset
  4850
     default is to redraw everything - subclasses should add intelligence"
claus
parents: 145
diff changeset
  4851
claus
parents: 145
diff changeset
  4852
    |area|
claus
parents: 145
diff changeset
  4853
claus
parents: 145
diff changeset
  4854
    shown ifFalse:[^ self].
claus
parents: 145
diff changeset
  4855
claus
parents: 145
diff changeset
  4856
    area := Rectangle left:x top:y width:w height:h.      
claus
parents: 145
diff changeset
  4857
    self clippedTo:area do:[
claus
parents: 145
diff changeset
  4858
"/        controller notNil ifTrue:[
claus
parents: 145
diff changeset
  4859
"/            "ST-80 updating"
claus
parents: 145
diff changeset
  4860
"/            self update:#rectangle with:area
claus
parents: 145
diff changeset
  4861
"/        ] ifFalse:[
claus
parents: 145
diff changeset
  4862
	    components notNil ifTrue:[
claus
parents: 145
diff changeset
  4863
		components do:[:aComponent |
claus
parents: 145
diff changeset
  4864
		    |thisFrame is|
claus
parents: 145
diff changeset
  4865
claus
parents: 145
diff changeset
  4866
		    thisFrame := aComponent frame.
claus
parents: 145
diff changeset
  4867
		    (thisFrame intersects:area) ifTrue:[
claus
parents: 145
diff changeset
  4868
			is := thisFrame intersect:(x@y extent:w@h).
claus
parents: 145
diff changeset
  4869
			is = thisFrame ifTrue:[
claus
parents: 145
diff changeset
  4870
			    aComponent redraw
claus
parents: 145
diff changeset
  4871
			] ifFalse:[
claus
parents: 145
diff changeset
  4872
			    aComponent redrawX:is left
claus
parents: 145
diff changeset
  4873
					     y:is top
claus
parents: 145
diff changeset
  4874
					 width:is width
claus
parents: 145
diff changeset
  4875
					height:is height.
claus
parents: 145
diff changeset
  4876
			].        
claus
parents: 145
diff changeset
  4877
			"/ aComponent drawIn:self offset:0@0
claus
parents: 145
diff changeset
  4878
		    ]
claus
parents: 145
diff changeset
  4879
		]
claus
parents: 145
diff changeset
  4880
	    ] ifFalse:[
claus
parents: 145
diff changeset
  4881
		self redraw
claus
parents: 145
diff changeset
  4882
	    ]
claus
parents: 145
diff changeset
  4883
"/        ]
claus
parents: 145
diff changeset
  4884
    ]                                                              
claus
parents: 145
diff changeset
  4885
!
claus
parents: 145
diff changeset
  4886
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4887
showActive
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4888
    "redraw myself as active (i.e. busy).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4889
     Nothing done here, but redefined in some classes."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4890
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4891
    ^ self
135
claus
parents:
diff changeset
  4892
!
claus
parents:
diff changeset
  4893
claus
parents:
diff changeset
  4894
showFocus
claus
parents:
diff changeset
  4895
    "highlight myself somehow to tell user that I have the focus"
claus
parents:
diff changeset
  4896
claus
parents:
diff changeset
  4897
    |delta|
claus
parents:
diff changeset
  4898
claus
parents:
diff changeset
  4899
    drawableId notNil ifTrue:[
claus
parents:
diff changeset
  4900
	delta := DefaultFocusBorderWidth - borderWidth.
claus
parents:
diff changeset
  4901
	delta ~~ 0 ifTrue:[
claus
parents:
diff changeset
  4902
	    device moveWindow:drawableId x:left-delta y:top-delta
claus
parents:
diff changeset
  4903
	].
claus
parents:
diff changeset
  4904
	device setWindowBorderWidth:DefaultFocusBorderWidth in:drawableId.
claus
parents:
diff changeset
  4905
	device setWindowBorderColor:(DefaultFocusColor on:device) colorId in:drawableId.
claus
parents:
diff changeset
  4906
    ]
claus
parents:
diff changeset
  4907
!
claus
parents:
diff changeset
  4908
claus
parents:
diff changeset
  4909
showNoFocus
claus
parents:
diff changeset
  4910
    "undo the effect of showFocus"
claus
parents:
diff changeset
  4911
claus
parents:
diff changeset
  4912
    |delta|
claus
parents:
diff changeset
  4913
claus
parents:
diff changeset
  4914
    drawableId notNil ifTrue:[
claus
parents:
diff changeset
  4915
	delta := DefaultFocusBorderWidth - borderWidth.
claus
parents:
diff changeset
  4916
	delta ~~ 0 ifTrue:[
claus
parents:
diff changeset
  4917
	    device moveWindow:drawableId x:left+delta y:top+delta
claus
parents:
diff changeset
  4918
	].
claus
parents:
diff changeset
  4919
	device setWindowBorderWidth:borderWidth in:drawableId.
claus
parents:
diff changeset
  4920
	self setBorderColor.
claus
parents:
diff changeset
  4921
    ]
claus
parents:
diff changeset
  4922
!
claus
parents:
diff changeset
  4923
claus
parents:
diff changeset
  4924
showPassive
claus
parents:
diff changeset
  4925
    "redraw myself as inactive (i.e. nonbusy).
151
claus
parents: 145
diff changeset
  4926
     Nothing done here, but redefined in some classes."
135
claus
parents:
diff changeset
  4927
claus
parents:
diff changeset
  4928
    ^ self
claus
parents:
diff changeset
  4929
! !
claus
parents:
diff changeset
  4930
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4931
!SimpleView methodsFor:'scrolling'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4932
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4933
horizontalScrollStep
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4934
    "return the amount to scroll when stepping left/right.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4935
     Subclasses may want to redefine this."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4936
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4937
    ^ (device horizontalPixelPerMillimeter * 20) asInteger
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4938
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4939
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4940
scrollDown
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4941
    "scroll down by some amount; this is called when the scrollbars
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4942
     scroll-step down button is pressed."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4943
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4944
    self scrollDown:(self verticalScrollStep)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4945
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4946
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4947
scrollHorizontalTo:aPixelOffset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4948
    "change origin to make aPixelOffset be the left col"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4949
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4950
    |orgX|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4951
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4952
    orgX := self viewOrigin x.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4953
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4954
    (aPixelOffset < orgX) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4955
	self scrollLeft:(orgX - aPixelOffset)
140
claus
parents: 138
diff changeset
  4956
    ] ifFalse:[
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4957
	(aPixelOffset > orgX) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4958
	    self scrollRight:(aPixelOffset - orgX)
140
claus
parents: 138
diff changeset
  4959
	]
claus
parents: 138
diff changeset
  4960
    ]
claus
parents: 138
diff changeset
  4961
!
claus
parents: 138
diff changeset
  4962
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4963
scrollHorizontalToPercent:percent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4964
    "scroll to a position given in percent of total"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4965
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4966
    |wCont|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4967
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4968
    wCont := self widthOfContents.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4969
    transformation notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4970
	wCont := transformation applyScaleX:wCont.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4971
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4972
    self scrollHorizontalTo:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4973
	    ((((wCont * percent) / 100.0) + 0.5) asInteger)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4974
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4975
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4976
scrollLeft
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4977
    "scroll left by some amount; this is called when the scrollbars
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4978
     scroll-step left button is pressed."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4979
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4980
    self scrollLeft:(self horizontalScrollStep)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4981
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4982
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4983
scrollRight
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4984
    "scroll right by some amount; this is called when the scrollbars
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4985
     scroll-step right button is pressed."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4986
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4987
    self scrollRight:(self horizontalScrollStep)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4988
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4989
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4990
scrollToTop
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4991
    "move viewOrigin to top"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4992
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4993
    self scrollVerticalTo:0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4994
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4995
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4996
scrollToTopLeft
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4997
    "move viewOrigin to top/left"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4998
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  4999
    self scrollTo:(0 @ 0).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5000
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5001
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5002
scrollUp
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5003
    "scroll up by some amount; this is called when the scrollbars
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5004
     scroll-step up button is pressed."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5005
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5006
    self scrollUp:(self verticalScrollStep)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5007
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5008
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5009
scrollVerticalTo:aPixelOffset
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5010
    "change origin to make aPixelOffset be the top line"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5011
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5012
    |orgY|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5013
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5014
    orgY := self viewOrigin y.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5015
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5016
    (aPixelOffset < orgY) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5017
	self scrollUp:(orgY - aPixelOffset)
140
claus
parents: 138
diff changeset
  5018
    ] ifFalse:[
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5019
	(aPixelOffset > orgY) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5020
	    self scrollDown:(aPixelOffset - orgY)
135
claus
parents:
diff changeset
  5021
	]
claus
parents:
diff changeset
  5022
    ]
claus
parents:
diff changeset
  5023
!
claus
parents:
diff changeset
  5024
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5025
scrollVerticalToPercent:percent
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5026
    "scroll to a position given in percent of total"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5027
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5028
    |hCont|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5029
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5030
    hCont := self heightOfContents.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5031
    transformation notNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5032
	hCont := transformation applyScaleY:hCont.
140
claus
parents: 138
diff changeset
  5033
    ].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5034
    self scrollVerticalTo:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5035
	    ((((hCont * percent) / 100.0) + 0.5) asInteger)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5036
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5037
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5038
verticalScrollStep
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5039
    "return the amount to scroll when stepping up/down.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5040
     Subclasses may want to redefine this."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5041
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5042
    ^ (device verticalPixelPerMillimeter * 20) asInteger
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5043
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5044
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5045
widthForScrollBetween:yStart and:yEnd 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5046
    "return the width in pixels for a scroll between yStart and yEnd
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5047
     - return full width here since we do not know how wide contents is.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5048
     Views which only use part of their space (short lists, text) may redefine
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5049
     this method and return the number of pixels that have to be scrolled.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5050
     On slow displays, this may make a difference; on fast ones you will probably
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5051
     not notice any difference."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5052
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5053
    ^ (width - margin - margin)
135
claus
parents:
diff changeset
  5054
! !
claus
parents:
diff changeset
  5055
claus
parents:
diff changeset
  5056
!SimpleView methodsFor:'scrolling-basic'!
claus
parents:
diff changeset
  5057
claus
parents:
diff changeset
  5058
scrollDown:nPixels
claus
parents:
diff changeset
  5059
    "change origin to scroll down some pixels"
claus
parents:
diff changeset
  5060
claus
parents:
diff changeset
  5061
    |count "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5062
     m2    "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5063
     w     "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5064
     h     "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5065
     hCont 
claus
parents:
diff changeset
  5066
     ih    "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5067
     orgX  
claus
parents:
diff changeset
  5068
     orgY  "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5069
     newOrigin|
claus
parents:
diff changeset
  5070
claus
parents:
diff changeset
  5071
    hCont := self heightOfContents.
claus
parents:
diff changeset
  5072
    transformation isNil ifTrue:[
claus
parents:
diff changeset
  5073
	orgY := orgX := 0
claus
parents:
diff changeset
  5074
    ] ifFalse:[
claus
parents:
diff changeset
  5075
	hCont := (transformation applyScaleY:hCont) rounded.
claus
parents:
diff changeset
  5076
	orgY := transformation translation y negated.
claus
parents:
diff changeset
  5077
	orgX := transformation translation x negated.
claus
parents:
diff changeset
  5078
    ].
claus
parents:
diff changeset
  5079
claus
parents:
diff changeset
  5080
    count := nPixels.
claus
parents:
diff changeset
  5081
    ih := self innerHeight.
claus
parents:
diff changeset
  5082
claus
parents:
diff changeset
  5083
    ((orgY + nPixels + ih) > hCont) ifTrue:[
claus
parents:
diff changeset
  5084
	count := hCont - orgY - ih
claus
parents:
diff changeset
  5085
    ].
claus
parents:
diff changeset
  5086
    (count <= 0) ifTrue:[^ self].
claus
parents:
diff changeset
  5087
claus
parents:
diff changeset
  5088
    self originWillChange.
claus
parents:
diff changeset
  5089
    newOrigin := orgX @ (orgY + count).
claus
parents:
diff changeset
  5090
    shown ifFalse:[
claus
parents:
diff changeset
  5091
	self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5092
    ] ifTrue:[
claus
parents:
diff changeset
  5093
	m2 := margin * 2.
claus
parents:
diff changeset
  5094
	(count >= ih) ifTrue:[
claus
parents:
diff changeset
  5095
	    self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5096
	    self redrawDeviceX:margin y:margin
claus
parents:
diff changeset
  5097
			 width:(width - m2)
claus
parents:
diff changeset
  5098
			height:(height - m2).
claus
parents:
diff changeset
  5099
	] ifFalse:[
claus
parents:
diff changeset
  5100
	    h := height - m2 - count.
claus
parents:
diff changeset
  5101
	    w := self width.
claus
parents:
diff changeset
  5102
	    self catchExpose.
claus
parents:
diff changeset
  5103
	    self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5104
	    self copyFrom:self x:margin y:(count + margin)
claus
parents:
diff changeset
  5105
			     toX:margin y:margin
claus
parents:
diff changeset
  5106
			   width:w 
claus
parents:
diff changeset
  5107
			  height:h.
claus
parents:
diff changeset
  5108
claus
parents:
diff changeset
  5109
	    self setInnerClip.
claus
parents:
diff changeset
  5110
	    self redrawDeviceX:margin y:(h + margin) 
claus
parents:
diff changeset
  5111
			 width:(width - m2) height:count.
claus
parents:
diff changeset
  5112
claus
parents:
diff changeset
  5113
	    self waitForExpose.
claus
parents:
diff changeset
  5114
	]
claus
parents:
diff changeset
  5115
    ].
claus
parents:
diff changeset
  5116
    self originChanged:(0 @ count).
claus
parents:
diff changeset
  5117
!
claus
parents:
diff changeset
  5118
claus
parents:
diff changeset
  5119
scrollLeft:nPixels
claus
parents:
diff changeset
  5120
    "change origin to scroll left some pixels"
claus
parents:
diff changeset
  5121
claus
parents:
diff changeset
  5122
    |count "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5123
     m2    "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5124
     h     "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5125
     orgX orgY newOrigin|
claus
parents:
diff changeset
  5126
claus
parents:
diff changeset
  5127
    transformation isNil ifTrue:[
claus
parents:
diff changeset
  5128
	orgY := orgX := 0
claus
parents:
diff changeset
  5129
    ] ifFalse:[
claus
parents:
diff changeset
  5130
	orgY := transformation translation y negated.
claus
parents:
diff changeset
  5131
	orgX := transformation translation x negated.
claus
parents:
diff changeset
  5132
    ].
claus
parents:
diff changeset
  5133
claus
parents:
diff changeset
  5134
    count := nPixels.
claus
parents:
diff changeset
  5135
    (count > orgX) ifTrue:[
claus
parents:
diff changeset
  5136
	count := orgX
claus
parents:
diff changeset
  5137
    ].
claus
parents:
diff changeset
  5138
    (count <= 0) ifTrue:[^ self].
claus
parents:
diff changeset
  5139
claus
parents:
diff changeset
  5140
    self originWillChange.
claus
parents:
diff changeset
  5141
    newOrigin := (orgX - count) @ orgY.
claus
parents:
diff changeset
  5142
claus
parents:
diff changeset
  5143
    shown ifFalse:[
claus
parents:
diff changeset
  5144
	self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5145
    ] ifTrue:[
claus
parents:
diff changeset
  5146
	m2 := margin * 2.
claus
parents:
diff changeset
  5147
	(count >= self innerWidth) ifTrue:[
claus
parents:
diff changeset
  5148
	    self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5149
	    self redrawDeviceX:margin y:margin
claus
parents:
diff changeset
  5150
			 width:(width - m2)
claus
parents:
diff changeset
  5151
			height:(height - m2).
claus
parents:
diff changeset
  5152
	] ifFalse:[
claus
parents:
diff changeset
  5153
	    h := (height - m2).
claus
parents:
diff changeset
  5154
claus
parents:
diff changeset
  5155
	    self catchExpose.
claus
parents:
diff changeset
  5156
	    self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5157
	    self copyFrom:self x:margin y:margin
claus
parents:
diff changeset
  5158
			     toX:(count + margin) y:margin
claus
parents:
diff changeset
  5159
			   width:(width - m2 - count) 
claus
parents:
diff changeset
  5160
			  height:h.
claus
parents:
diff changeset
  5161
claus
parents:
diff changeset
  5162
	    self setInnerClip.
claus
parents:
diff changeset
  5163
	    self redrawDeviceX:margin y:margin
claus
parents:
diff changeset
  5164
			 width:count height:(height - m2).
claus
parents:
diff changeset
  5165
claus
parents:
diff changeset
  5166
	    self waitForExpose.
claus
parents:
diff changeset
  5167
	]
claus
parents:
diff changeset
  5168
    ].
claus
parents:
diff changeset
  5169
    self originChanged:(count negated @ 0).
claus
parents:
diff changeset
  5170
!
claus
parents:
diff changeset
  5171
claus
parents:
diff changeset
  5172
scrollRight:nPixels
claus
parents:
diff changeset
  5173
    "change origin to scroll right some pixels"
claus
parents:
diff changeset
  5174
claus
parents:
diff changeset
  5175
    |count "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5176
     m2    "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5177
     h     "{ Class:SmallInteger }" 
claus
parents:
diff changeset
  5178
     wCont 
claus
parents:
diff changeset
  5179
     iw    "{ Class:SmallInteger }"
claus
parents:
diff changeset
  5180
     orgX orgY newOrigin|
claus
parents:
diff changeset
  5181
claus
parents:
diff changeset
  5182
    wCont := self widthOfContents.
claus
parents:
diff changeset
  5183
    transformation isNil ifTrue:[
claus
parents:
diff changeset
  5184
	orgY := orgX := 0
claus
parents:
diff changeset
  5185
    ] ifFalse:[
claus
parents:
diff changeset
  5186
	wCont := (transformation applyScaleX:wCont) rounded.
claus
parents:
diff changeset
  5187
	orgY := transformation translation y negated.
claus
parents:
diff changeset
  5188
	orgX := transformation translation x negated.
claus
parents:
diff changeset
  5189
    ].
claus
parents:
diff changeset
  5190
claus
parents:
diff changeset
  5191
    count := nPixels.
claus
parents:
diff changeset
  5192
    iw := self innerWidth.
claus
parents:
diff changeset
  5193
claus
parents:
diff changeset
  5194
    ((orgX + nPixels + iw) > wCont) ifTrue:[
claus
parents:
diff changeset
  5195
	count := wCont - orgX - iw
claus
parents:
diff changeset
  5196
    ].
claus
parents:
diff changeset
  5197
    (count <= 0) ifTrue:[^ self].
claus
parents:
diff changeset
  5198
claus
parents:
diff changeset
  5199
    self originWillChange.
claus
parents:
diff changeset
  5200
    newOrigin := (orgX + count) @ orgY.
claus
parents:
diff changeset
  5201
claus
parents:
diff changeset
  5202
    shown ifFalse:[
claus
parents:
diff changeset
  5203
	self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5204
    ] ifTrue:[
claus
parents:
diff changeset
  5205
	m2 := margin * 2.
claus
parents:
diff changeset
  5206
	(count >= iw) ifTrue:[
claus
parents:
diff changeset
  5207
	    self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5208
	    self redrawDeviceX:margin y:margin
claus
parents:
diff changeset
  5209
			 width:(width - m2)
claus
parents:
diff changeset
  5210
			height:(height - m2).
claus
parents:
diff changeset
  5211
	] ifFalse:[
claus
parents:
diff changeset
  5212
	    m2 := margin * 2.
claus
parents:
diff changeset
  5213
	    h := (height - m2).
claus
parents:
diff changeset
  5214
claus
parents:
diff changeset
  5215
	    self catchExpose.
claus
parents:
diff changeset
  5216
	    self setViewOrigin:newOrigin.
claus
parents:
diff changeset
  5217
	    self copyFrom:self x:(count + margin) y:margin
claus
parents:
diff changeset
  5218
			     toX:margin y:margin
claus
parents:
diff changeset
  5219
			   width:(width - m2 - count) 
claus
parents:
diff changeset
  5220
			  height:h.
claus
parents:
diff changeset
  5221
claus
parents:
diff changeset
  5222
	    self setInnerClip.
claus
parents:
diff changeset
  5223
	    self redrawDeviceX:(width - margin - count) y:margin 
claus
parents:
diff changeset
  5224
			 width:count height:(height - m2).
claus
parents:
diff changeset
  5225
claus
parents:
diff changeset
  5226
	    self waitForExpose.
claus
parents:
diff changeset
  5227
	].
claus
parents:
diff changeset
  5228
    ].
claus
parents:
diff changeset
  5229
    self originChanged:(count @ 0).
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5230
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5231
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5232
scrollTo:newOrigin 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5233
    "change origin to have newOrigin be visible at the top-left.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5234
     The argument defines the integer device coordinates of the new top-left 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5235
     point."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5236
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5237
    "due to historic reasons, the work is actually done by scrollUp/Down
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5238
     scrollLeft/Right (those where implemented first).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5239
     This will be changed to do all work here, and call it from
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5240
     the other scrolling methods."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5241
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5242
    |dX   "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5243
     dY   "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5244
     m2   "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5245
     orgX "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5246
     orgY "{ Class:SmallInteger }" |
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5247
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5248
    transformation isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5249
	orgY := orgX := 0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5250
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5251
	orgY := transformation translation y negated.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5252
	orgX := transformation translation x negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5253
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5254
    dX := newOrigin x - orgX.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5255
    dY := newOrigin y - orgY.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5256
    dX = 0 ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5257
	dY < 0 ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5258
	    ^ self scrollUp:(dY negated).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5259
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5260
	dY > 0 ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5261
	    ^ self scrollDown:dY.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5262
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5263
	^ self
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5264
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5265
    dY = 0 ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5266
	dX < 0 ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5267
	    ^ self scrollLeft:dX negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5268
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5269
	dX > 0 ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5270
	    ^ self scrollRight:dX
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5271
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5272
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5273
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5274
    self originWillChange.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5275
    self setViewOrigin:newOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5276
    shown ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5277
	m2 := margin * 2. "top & bottom margins"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5278
	self redrawDeviceX:margin y:margin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5279
		     width:(width - m2)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5280
		    height:(height - m2).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5281
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5282
    self originChanged:(dX @ dY).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5283
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5284
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5285
scrollUp:nPixels
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5286
    "change origin to scroll up (towards the origin) by some pixels"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5287
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5288
    |count "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5289
     m2    "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5290
     w     "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5291
     h     "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5292
     orgX
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5293
     orgY  "{ Class:SmallInteger }"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5294
     newOrigin|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5295
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5296
    transformation isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5297
	orgY := orgX := 0
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5298
    ] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5299
	orgY := transformation translation y negated.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5300
	orgX := transformation translation x negated
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5301
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5302
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5303
    count := nPixels.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5304
    (count > orgY) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5305
	count := orgY
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5306
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5307
    (count <= 0) ifTrue:[^ self].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5308
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5309
    self originWillChange.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5310
    newOrigin := orgX @ (orgY - count).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5311
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5312
    shown ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5313
	self setViewOrigin:newOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5314
    ] ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5315
	m2 := margin * 2. "top & bottom margins"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5316
	(count >= self innerHeight) ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5317
	    self setViewOrigin:newOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5318
	    self redrawDeviceX:margin y:margin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5319
			 width:(width - m2)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5320
			height:(height - m2).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5321
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5322
	    h := height - m2 - count.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5323
	    w := width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5324
	    self catchExpose.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5325
	    self setViewOrigin:newOrigin.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5326
	    self copyFrom:self x:margin y:margin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5327
			     toX:margin y:(count + margin)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5328
			   width:w height:h.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5329
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5330
	    self setInnerClip.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5331
	    self redrawDeviceX:margin y:margin
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5332
			 width:(width - m2)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5333
			height:count.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5334
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5335
	    self waitForExpose.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5336
	]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5337
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5338
    self originChanged:(0 @ count negated).
135
claus
parents:
diff changeset
  5339
! !
claus
parents:
diff changeset
  5340
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5341
!SimpleView methodsFor:'startup'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5342
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5343
open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5344
    "open up the view - for normal views, this is a modeless open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5345
     (i.e. the new view comes up as independent process).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5346
     Although #open is only to be sent to topviews (i.e. it could have been
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5347
     implemented in TopView), it is implemented here - therefore, every view
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5348
     can be opened as a topView.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5349
     This is redefined in ModalBox, which comes up modal (i.e. 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5350
     control is under the current process, so that interaction with the
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5351
     current group is blocked while the modalBox is active)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5352
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5353
    ^ self openModeless
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5354
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5355
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5356
     View new open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5357
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5358
     (Button label:'hello') open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5359
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5360
     |top|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5361
     top := StandardSystemView new.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5362
     top extent:200@200.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5363
     Button label:'hello' in:top.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5364
     top open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5365
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5366
     YesNoBox new open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5367
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5368
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5369
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5370
openAndWait
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5371
    "open up the view - wait until it is visible.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5372
     In normal applications, you do not need to wait till the view is
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5373
     open - it should do all of its drawing itself when it gets the
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5374
     first expose event.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5375
     However, if you want to 'manually' draw into the view (for example,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5376
     in doIt expressions) the view must be visible (realized) before doing so.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5377
     Use this open in those situations."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5378
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5379
    self open.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5380
    self waitUntilVisible.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5381
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5382
    "does not work:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5383
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5384
	|v|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5385
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5386
	v := View new open.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5387
	v displayLineFrom:0@0 to:50@50
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5388
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5389
     does work:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5390
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5391
	|v|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5392
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5393
	v := View new openAndWait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5394
	v displayLineFrom:0@0 to:50@50
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5395
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5396
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5397
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5398
openAt:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5399
    "open up the view modeless - positions the view"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5400
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5401
    ^self openModelessAt:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5402
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5403
    "Created: 18.9.1995 / 23:30:43 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5404
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5405
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5406
openAtCenter
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5407
    "open up the view modeless - positions the view"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5408
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5409
    ^self openModelessAtCenter
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5410
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5411
    "Created: 18.9.1995 / 23:30:56 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5412
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5413
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5414
openAutonomous
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5415
    "create and schedule a new windowgroup for me and open the view.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5416
     The view will be handled by its own process, effectively running in
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5417
     parallel. This entry is for non-topviews, which want to be served
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5418
     autonomous from the topview. (see the fileBrowsers kill-button
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5419
     when executing unix commands as an example)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5420
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5421
    |wg|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5422
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5423
    ProcessorScheduler isPureEventDriven ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5424
	wg := WindowGroup new.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5425
	self windowGroup:wg.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5426
	wg addView:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5427
	wg startup:false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5428
	self realizeInGroup.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5429
    ] ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5430
	self realize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5431
    ]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5432
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5433
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5434
openModal
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5435
    "create a new windowgroup, but start processing in the current process
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5436
     actually suspending event processing for the currently active group.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5437
     Stay in modalLoop while view is visible.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5438
     (i.e. control is returned to the sender when the receiver is closed)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5439
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5440
    self openModal:[true]
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5441
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5442
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5443
     the same:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5444
	 YesNoBox new open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5445
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5446
	 YesNoBox new openModal
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5447
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5448
     different:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5449
	 (Button label:'hello') open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5450
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5451
	 (Button label:'hello') openModal
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5452
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5453
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5454
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5455
openModal:aBlock
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5456
    "create a new windowgroup, but start processing in the current process -
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5457
     actually suspending event processing for the currently active group.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5458
     Stay in this modal loop while aBlock evaluates to true AND the receiver is
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5459
     visible.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5460
     (i.e. control is returned to the sender when the receiver is closed)
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5461
     This makes any interaction with the current window impossible - 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5462
     however, other views (in other windowgroups) still work."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5463
299
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5464
    ^ self openModal:aBlock inGroup:WindowGroup activeGroup.
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5465
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5466
    "Created: 10.12.1995 / 14:06:45 / cg"
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5467
    "Modified: 10.12.1995 / 14:08:48 / cg"
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5468
!
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5469
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5470
openModal:aBlock inGroup:mainGroup
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5471
    "create a new windowgroup, but start processing in the current process -
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5472
     actually suspending event processing for the main group.
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5473
     Stay in this modal loop while aBlock evaluates to true AND the receiver is
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5474
     visible.
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5475
     (i.e. control is returned to the sender when the receiver is closed)
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5476
     This makes any interaction with the current window impossible - 
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5477
     however, other views (in other windowgroups) still work."
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5478
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5479
    |tops|
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5480
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5481
    Processor activeProcessIsSystemProcess ifTrue:[
312
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5482
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5483
	 put myself into the modal group, let it handle events for
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5484
	 me as well. This is only a half way solution, since the view
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5485
	 is not modal at all ... however, the only situation
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5486
	 where this happens is with modal boxes popped while in a
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5487
	 modal browser. You will forgive me for that inconvenience.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5488
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5489
	windowGroup := mainGroup.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5490
	mainGroup notNil ifTrue:[mainGroup addTopView:self].
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5491
	self realize
135
claus
parents:
diff changeset
  5492
    ] ifFalse:[
312
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5493
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5494
	 create a new window group and put myself into it
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5495
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5496
	windowGroup := WindowGroup new.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5497
	windowGroup addTopView:self.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5498
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5499
	 go dispatch events in this new group
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5500
	 (thus current windowgroup is blocked from interaction)
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5501
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5502
	Object abortSignal handle:[:ex |
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5503
	    self hide.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5504
	    ex return.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5505
	] do:[
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5506
	    [
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5507
		windowGroup startupModal:[realized and:aBlock] forGroup:mainGroup
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5508
	    ] valueOnUnwindDo:[
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5509
		self hide.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5510
	    ]
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5511
	].
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5512
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5513
	 return input focus to previously active groups top.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5514
	 This helps with windowmanagers which need an explicit click
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5515
	 on the view for the focus.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5516
	"
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5517
	mainGroup notNil ifTrue:[
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5518
	    tops := mainGroup topViews.
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5519
	    (tops notNil and:[tops notEmpty]) ifTrue:[
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5520
		tops first getKeyboardFocus
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5521
	    ]
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5522
	]
135
claus
parents:
diff changeset
  5523
    ]
299
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5524
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5525
    "Created: 10.12.1995 / 14:06:14 / cg"
e2c8fd828a64 passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  5526
    "Modified: 10.12.1995 / 14:15:36 / cg"
135
claus
parents:
diff changeset
  5527
!
claus
parents:
diff changeset
  5528
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5529
openModalAt:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5530
    "open up the view modeless - positions the view
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5531
     (i.e. circumvents window managers positioning)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5532
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5533
    self origin:aPoint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5534
    self create.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5535
    device setTransient:drawableId for:0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5536
    ^ self openModal
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5537
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5538
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5539
     View new openModal
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5540
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5541
     View new openModalAt:100@100
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5542
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5543
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5544
    "Created: 18.9.1995 / 23:21:42 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5545
    "Modified: 18.9.1995 / 23:32:26 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5546
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5547
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5548
openModalAtCenter
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5549
    "open up the view modeless - positions the view
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5550
     (i.e. circumvents window managers positioning)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5551
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5552
    ^ self openModalAt:(device center - (self extent//2)).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5553
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5554
    "Created: 18.9.1995 / 23:31:47 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5555
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5556
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5557
openModeless
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5558
    "create and schedule a new windowgroup for me and open the view.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5559
     The view will be handled by its own process, effectively running in
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5560
     parallel (i.e. control is returned to the sender immediately)."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5561
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5562
    ProcessorScheduler isPureEventDriven ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5563
	windowGroup isNil ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5564
	    windowGroup := WindowGroup new.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5565
	    windowGroup addTopView:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5566
	    windowGroup startup:false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5567
	] ifFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5568
	    windowGroup startup:false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5569
	    self realizeInGroup.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5570
	].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5571
    ] ifTrue:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5572
	self realize
135
claus
parents:
diff changeset
  5573
    ]
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5574
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5575
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5576
     the same:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5577
	 (Button label:'hello') open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5578
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5579
	 (Button label:'hello') openModeless
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5580
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5581
     different:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5582
	 YesNoBox new open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5583
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5584
	 YesNoBox new openModeless
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5585
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5586
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5587
     (almost) the same:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5588
	 YesNoBox new open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5589
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5590
	 YesNoBox new openModal
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5591
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5592
     different:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5593
	 (Button label:'hello') open
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5594
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5595
	 (Button label:'hello') openModal
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5596
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5597
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5598
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5599
openModelessAt:aPoint
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5600
    "open up the view modeless - positions the view
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5601
     (i.e. circumvents window managers positioning)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5602
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5603
    self origin:aPoint.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5604
    self create.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5605
    device setTransient:drawableId for:0.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5606
    ^ self openModeless
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5607
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5608
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5609
     View new openModeless
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5610
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5611
     View new openModelessAt:100@100
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5612
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5613
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5614
    "Created: 18.9.1995 / 23:21:42 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5615
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5616
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5617
openModelessAtCenter
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5618
    "open up the view modeless - positions the view
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5619
     (i.e. circumvents window managers positioning)"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5620
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5621
    ^ self openModelessAt:(device center - (self extent//2)).
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5622
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5623
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5624
     View new openModeless
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5625
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5626
     View new openModelessAtCenter
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5627
    "
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5628
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5629
    "Created: 18.9.1995 / 23:21:42 / claus"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5630
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5631
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5632
waitUntilVisible
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5633
    "wait until the receiver visible.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5634
     In normal applications, you do not need to wait till a view is
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5635
     open - it should do all of its drawing itself when it gets the
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5636
     first expose event.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5637
     However, if you want to 'manually' draw into the view (for example,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5638
     in doIt expressions), or subsequent views depend on some state of
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5639
     another view (which is only available once visible), 
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5640
     use this to suspend the current process until the receiver is shown.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5641
     Caveat:
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5642
	we poll here for the view to be shown - we need a semaphore
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5643
	which is raised by the view in order to do it right."
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5644
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5645
    [self shown] whileFalse:[
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5646
	(Delay forSeconds:0.05) wait.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5647
    ].
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5648
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5649
    "does not work (the view is in its opening phase,
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5650
     when we attempt to draw a line - this gives an error, since
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5651
     its internals are not yet correctly setup):
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5652
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5653
	|v|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5654
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5655
	v := View new open.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5656
	v displayLineFrom:0@0 to:50@50
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5657
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5658
     does work (since we wait until the view has completely finished
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5659
     its startup phase):
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5660
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5661
	|v|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5662
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5663
	v := View new open.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5664
	v waitUntilVisible.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5665
	v displayLineFrom:0@0 to:50@50
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5666
    "
135
claus
parents:
diff changeset
  5667
! !
claus
parents:
diff changeset
  5668
claus
parents:
diff changeset
  5669
!SimpleView methodsFor:'user notification'!
claus
parents:
diff changeset
  5670
claus
parents:
diff changeset
  5671
warn:aString
claus
parents:
diff changeset
  5672
    "like Objects warn, but translates the string via the
claus
parents:
diff changeset
  5673
     resourcePack, thus giving a translated string automatically"
claus
parents:
diff changeset
  5674
151
claus
parents: 145
diff changeset
  5675
    super warn:(resources string:aString) withCRs
135
claus
parents:
diff changeset
  5676
!
claus
parents:
diff changeset
  5677
claus
parents:
diff changeset
  5678
warn:aString with:argument
claus
parents:
diff changeset
  5679
    "like Objects warn, but translates the string via the
claus
parents:
diff changeset
  5680
     resourcePack, thus giving a translated string automatically"
claus
parents:
diff changeset
  5681
151
claus
parents: 145
diff changeset
  5682
    super warn:(resources string:aString with:argument) withCRs
claus
parents: 145
diff changeset
  5683
!
claus
parents: 145
diff changeset
  5684
claus
parents: 145
diff changeset
  5685
warn:aString with:arg1 with:arg2
claus
parents: 145
diff changeset
  5686
    "like Objects warn, but translates the string via the
claus
parents: 145
diff changeset
  5687
     resourcePack, thus giving a translated string automatically"
claus
parents: 145
diff changeset
  5688
claus
parents: 145
diff changeset
  5689
    super warn:(resources string:aString with:arg1 with:arg2) withCRs
135
claus
parents:
diff changeset
  5690
! !
claus
parents:
diff changeset
  5691
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5692
!SimpleView class methodsFor:'documentation'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5693
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
  5694
version
312
a3500ca1f37b stefans changes
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
  5695
    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.34 1995-12-14 17:39:48 cg Exp $'
135
claus
parents:
diff changeset
  5696
! !
claus
parents:
diff changeset
  5697
SimpleView initialize!