StandardSystemView.st
changeset 1878 76e9bc8e1b9c
parent 1865 43c2eaba229d
child 1880 2900f8770585
equal deleted inserted replaced
1877:6c7c5d6ad7f5 1878:76e9bc8e1b9c
    12 
    12 
    13 TopView subclass:#StandardSystemView
    13 TopView subclass:#StandardSystemView
    14 	instanceVariableNames:'label icon iconView iconLabel minExtent maxExtent sizeFixed
    14 	instanceVariableNames:'label icon iconView iconLabel minExtent maxExtent sizeFixed
    15 		application windowEventsForApplication'
    15 		application windowEventsForApplication'
    16 	classVariableNames:'DefaultIcon TakeFocusWhenMapped IncludeHostNameInLabel
    16 	classVariableNames:'DefaultIcon TakeFocusWhenMapped IncludeHostNameInLabel
    17 		DefaultExtent'
    17 		DefaultExtent NewHostNameInLabelFormat'
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Views-Basic'
    19 	category:'Views-Basic'
    20 !
    20 !
    21 
    21 
    22 !StandardSystemView class methodsFor:'documentation'!
    22 !StandardSystemView class methodsFor:'documentation'!
    47 
    47 
    48     In ST/X, StandardSystemViews were subclassed for special views
    48     In ST/X, StandardSystemViews were subclassed for special views
    49     in the past (for example: FileBrowser, ChangesBrowser etc.).
    49     in the past (for example: FileBrowser, ChangesBrowser etc.).
    50     Although this worked, it may lead to the following
    50     Although this worked, it may lead to the following
    51     problems and inconveniences:
    51     problems and inconveniences:
    52 	- applications inherit a big number of methods through the
    52         - applications inherit a big number of methods through the
    53 	  SimpleView->View->TopView->StandardSystemView hierarchy.
    53           SimpleView->View->TopView->StandardSystemView hierarchy.
    54 	  There is quite a danger that by accident, some method gets
    54           There is quite a danger that by accident, some method gets
    55 	  redefined which is required by one of those classes.
    55           redefined which is required by one of those classes.
    56 	  (typical candidates are: terminate, destroy, open ...)
    56           (typical candidates are: terminate, destroy, open ...)
    57 	  This may lead to strange effects, which may not be obvious to
    57           This may lead to strange effects, which may not be obvious to
    58 	  non experts ...
    58           non experts ...
    59 
    59 
    60 	- applications with multiple topViews are difficult to implement
    60         - applications with multiple topViews are difficult to implement
    61 	  and manage.
    61           and manage.
    62 
    62 
    63 	- use of a windowBuilder is difficult.
    63         - use of a windowBuilder is difficult.
    64 
    64 
    65     For all those reasons, we HIGHLY recommend to NOT define applications
    65     For all those reasons, we HIGHLY recommend to NOT define applications
    66     as subclasses of StandardSystemView, but instead base them on
    66     as subclasses of StandardSystemView, but instead base them on
    67     ApplicationModel, and reference the topView(s) as instance variables of
    67     ApplicationModel, and reference the topView(s) as instance variables of
    68     if (if at all).
    68     if (if at all).
    69 
    69 
    70     [instance variables:]
    70     [instance variables:]
    71 	label                   <String>    the label in the windows title
    71         label                   <String>    the label in the windows title
    72 
    72 
    73 	icon                    <Form>      the icon
    73         icon                    <Form>      the icon
    74 					    [ignored if the display does not 
    74                                             [ignored if the display does not 
    75 					     support icons]
    75                                              support icons]
    76 
    76 
    77 	iconView                <View>      an optional icon-view (for animated icons)
    77         iconView                <View>      an optional icon-view (for animated icons)
    78 					    [ignored if the display does not
    78                                             [ignored if the display does not
    79 					     supports this]
    79                                              supports this]
    80 
    80 
    81 	iconLabel               <String>    the label in the icon
    81         iconLabel               <String>    the label in the icon
    82 					    [ignored if the display does not 
    82                                             [ignored if the display does not 
    83 					     support label-tabs with icons]
    83                                              support label-tabs with icons]
    84 
    84 
    85 	minExtent               <Point>     the minimum size
    85         minExtent               <Point>     the minimum size
    86 					    No limit, if nil
    86                                             No limit, if nil
    87 					    [the window manager may have its own
    87                                             [the window manager may have its own
    88 					     limit; typically some small area]
    88                                              limit; typically some small area]
    89 
    89 
    90 	maxExtent               <Point>     the maximum size
    90         maxExtent               <Point>     the maximum size
    91 					    No limit, if nil.
    91                                             No limit, if nil.
    92 					    [the window manager may have its own
    92                                             [the window manager may have its own
    93 					     limit; typically the screen size]
    93                                              limit; typically the screen size]
    94 
    94 
    95 	sizeFixed               <Boolean>   prevents the view from resizing itself
    95         sizeFixed               <Boolean>   prevents the view from resizing itself
    96 					    (especially to freeze a dialogs size)
    96                                             (especially to freeze a dialogs size)
    97 
    97 
    98 	application             <AppModel>  if nonNil, thats the application
    98         application             <AppModel>  if nonNil, thats the application
    99 					    Many requests (such as open/close etc.
    99                                             Many requests (such as open/close etc.
   100 					    are forwarded to it, if present.
   100                                             are forwarded to it, if present.
   101 
   101 
   102 
   102 
   103 
   103 
   104      [class variables:]
   104      [class variables:]
   105 
   105 
   106 	DefaultIcon             <Form>      cached default icon
   106         DefaultIcon             <Form>      cached default icon
   107 
   107 
   108 	TakeFocusWhenMapped     <Boolean>   if true, views grab the keyboard
   108         TakeFocusWhenMapped     <Boolean>   if true, views grab the keyboard
   109 					    focus (convenient with some stupid
   109                                             focus (convenient with some stupid
   110 					    windowManagers)
   110                                             windowManagers)
   111 
   111 
   112 	IncludeHostNameInLabel  <Boolean>   if true, the windows title shall
   112         IncludeHostNameInLabel  <Boolean>   if true, the windows title shall
   113 					    include the hostname.
   113                                             include the hostname.
   114 					    (convenient if you have many remote
   114                                             (convenient if you have many remote
   115 					    views open simultaneously)
   115                                             views open simultaneously)
       
   116 
       
   117         NewHostNameInLabelFormat <Boolean>  if true, the hostname is appended
       
   118                                             after a '@'-character.
       
   119                                             If false, its prepended with a colon.
       
   120                                             The first is better with window managers
       
   121                                             which cut of the tail of the window
       
   122                                             title for the icon-bar (i.e. fvwm95)
       
   123                                         
   116 
   124 
   117     [author:]
   125     [author:]
   118 	Claus Gittinger
   126         Claus Gittinger
   119 
   127 
   120     [see also:]
   128     [see also:]
   121 	WindowGroup
   129         WindowGroup
   122 	ApplicationModel
   130         ApplicationModel
   123 "
   131 "
   124 !
   132 !
   125 
   133 
   126 examples
   134 examples
   127 "
   135 "
   316      and extent-boundaries."
   324      and extent-boundaries."
   317 
   325 
   318     ^ self origin:anOrigin extent:nil
   326     ^ self origin:anOrigin extent:nil
   319 	   label:aLabel icon:aForm
   327 	   label:aLabel icon:aForm
   320 	   minExtent:minExtent maxExtent:maxExtent
   328 	   minExtent:minExtent maxExtent:maxExtent
       
   329 ! !
       
   330 
       
   331 !StandardSystemView class methodsFor:'class initialization'!
       
   332 
       
   333 initialize
       
   334     IncludeHostNameInLabel := false.
       
   335     NewHostNameInLabelFormat := true.
       
   336     TakeFocusWhenMapped := false.
       
   337 
       
   338     "Created: 20.8.1997 / 14:16:32 / cg"
       
   339     "Modified: 20.8.1997 / 14:16:45 / cg"
   321 ! !
   340 ! !
   322 
   341 
   323 !StandardSystemView class methodsFor:'defaults'!
   342 !StandardSystemView class methodsFor:'defaults'!
   324 
   343 
   325 defaultExtent
   344 defaultExtent
   720     "define the views name in the windows title area.
   739     "define the views name in the windows title area.
   721      If IncludeHostNameInLabel is true, prepend the hostname
   740      If IncludeHostNameInLabel is true, prepend the hostname
   722      (you will appreciate this, if you are working on multiple
   741      (you will appreciate this, if you are working on multiple
   723       machines simultaneously - as I do ...)"
   742       machines simultaneously - as I do ...)"
   724 
   743 
   725     |l|
   744     |l hostName|
   726 
   745 
   727     aString ~= label ifTrue:[
   746     aString ~= label ifTrue:[
   728 	label := aString.
   747         label := aString.
   729 	drawableId notNil ifTrue: [
   748         drawableId notNil ifTrue: [
   730 	    IncludeHostNameInLabel == true ifTrue:[
   749             IncludeHostNameInLabel == true ifTrue:[
   731 		l := OperatingSystem getHostName , ': ' , aString.
   750                 hostName := OperatingSystem getHostName.
   732 	    ] ifFalse:[
   751                 NewHostNameInLabelFormat == true ifTrue:[
   733 		l := aString
   752                     l := aString , '@' , hostName
   734 	    ].
   753                 ] ifFalse:[
   735 	    device setWindowName:l in:drawableId.
   754                     l := hostName , ': ' , aString.
   736 	    "
   755                 ]
   737 	     unbuffered - to make it visible right NOW
   756             ] ifFalse:[
   738 	    "
   757                 l := aString
   739 	    device flush.
   758             ].
   740 	]
   759             device setWindowName:l in:drawableId.
       
   760             "
       
   761              unbuffered - to make it visible right NOW
       
   762             "
       
   763             device flush.
       
   764         ]
   741     ]
   765     ]
   742 
   766 
   743     "Created: 8.9.1995 / 19:37:06 / claus"
   767     "Created: 8.9.1995 / 19:37:06 / claus"
   744     "Modified: 8.9.1995 / 19:39:18 / claus"
   768     "Modified: 8.9.1995 / 19:39:18 / claus"
   745     "Modified: 24.4.1996 / 09:09:17 / cg"
   769     "Modified: 20.8.1997 / 14:18:01 / cg"
   746 !
   770 !
   747 
   771 
   748 label:labelString iconLabel:iconLabelString
   772 label:labelString iconLabel:iconLabelString
   749     "set both the label and the iconLabel"
   773     "set both the label and the iconLabel"
   750 
   774 
  1236 !
  1260 !
  1237 
  1261 
  1238 physicalCreate
  1262 physicalCreate
  1239     "common code for create & recreate"
  1263     "common code for create & recreate"
  1240 
  1264 
  1241     |l icn icnMask org listener ret|
  1265     |hostName l icn icnMask org listener ret|
  1242 
  1266 
  1243     IncludeHostNameInLabel == true ifTrue:[
  1267     IncludeHostNameInLabel == true ifTrue:[
  1244 	l := OperatingSystem getHostName , ': ' , label.
  1268         hostName := OperatingSystem getHostName.
       
  1269         NewHostNameInLabelFormat == true ifTrue:[
       
  1270             l := label , '@' , hostName
       
  1271         ] ifFalse:[
       
  1272             l := hostName , ': ' , label.
       
  1273         ]
  1245     ] ifFalse:[
  1274     ] ifFalse:[
  1246 	l := label
  1275         l := label
  1247     ].
  1276     ].
  1248 
  1277 
  1249     icon notNil ifTrue:[
  1278     icon notNil ifTrue:[
  1250 	icn := self convertedIcon:icon.
  1279         icn := self convertedIcon:icon.
  1251 	(icnMask := icon mask) notNil ifTrue:[
  1280         (icnMask := icon mask) notNil ifTrue:[
  1252 	    icnMask := self convertedIconMask:icnMask
  1281             icnMask := self convertedIconMask:icnMask
  1253 	]
  1282         ]
  1254     ].
  1283     ].
  1255 
  1284 
  1256     org := left @ top.
  1285     org := left @ top.
  1257 
  1286 
  1258     "/ if there is a global eventListener,
  1287     "/ if there is a global eventListener,
  1265             org := ret
  1294             org := ret
  1266         ]
  1295         ]
  1267     ].
  1296     ].
  1268 
  1297 
  1269     drawableId := device 
  1298     drawableId := device 
  1270 		      createWindowFor:self 
  1299                       createWindowFor:self 
  1271 		      type:nil
  1300                       type:nil
  1272 		      origin:org
  1301                       origin:org
  1273 		      extent:(width @ height)
  1302                       extent:(width @ height)
  1274 		      minExtent:minExtent
  1303                       minExtent:minExtent
  1275 		      maxExtent:maxExtent
  1304                       maxExtent:maxExtent
  1276 		      borderWidth:borderWidth
  1305                       borderWidth:borderWidth
  1277 		      subViewOf:nil 
  1306                       subViewOf:nil 
  1278 		      style:(self windowStyle)
  1307                       style:(self windowStyle)
  1279 		      inputOnly:(self isInputOnly)
  1308                       inputOnly:(self isInputOnly)
  1280 		      label:l
  1309                       label:l
  1281 		      cursor:cursor
  1310                       cursor:cursor
  1282 		      icon:icn iconMask:icnMask
  1311                       icon:icn iconMask:icnMask
  1283 		      iconView:iconView.
  1312                       iconView:iconView.
  1284 
  1313 
  1285     Lobby registerChange:self.
  1314     Lobby registerChange:self.
  1286 
  1315 
  1287     "/ if there is a global eventListener,
  1316     "/ if there is a global eventListener,
  1288     "/ give it a chance to track views
  1317     "/ give it a chance to track views
  1293 
  1322 
  1294     extentChanged := false.
  1323     extentChanged := false.
  1295     originChanged := false.
  1324     originChanged := false.
  1296 
  1325 
  1297     (borderColor notNil and:[borderColor ~= Black]) ifTrue:[
  1326     (borderColor notNil and:[borderColor ~= Black]) ifTrue:[
  1298 	self setBorderColor
  1327         self setBorderColor
  1299     ].
  1328     ].
  1300 
  1329 
  1301 "/  (viewGravity notNil "and:[viewGravity ~~ #NorthWest]") ifTrue:[
  1330 "/  (viewGravity notNil "and:[viewGravity ~~ #NorthWest]") ifTrue:[
  1302 "/        device setWindowGravity:viewGravity in:drawableId
  1331 "/        device setWindowGravity:viewGravity in:drawableId
  1303 "/  ].
  1332 "/  ].
  1305 "/  (bitGravity notNil "and:[bitGravity ~~ #NorthWest]") ifTrue:[
  1334 "/  (bitGravity notNil "and:[bitGravity ~~ #NorthWest]") ifTrue:[
  1306 "/      device setBitGravity:bitGravity in:drawableId
  1335 "/      device setBitGravity:bitGravity in:drawableId
  1307 "/  ].
  1336 "/  ].
  1308 
  1337 
  1309     borderShape notNil ifTrue:[
  1338     borderShape notNil ifTrue:[
  1310 	device setWindowBorderShape:(borderShape id) in:drawableId
  1339         device setWindowBorderShape:(borderShape id) in:drawableId
  1311     ].
  1340     ].
  1312     viewShape notNil ifTrue:[
  1341     viewShape notNil ifTrue:[
  1313 	device setWindowShape:(viewShape id) in:drawableId
  1342         device setWindowShape:(viewShape id) in:drawableId
  1314     ].
  1343     ].
  1315     (backed notNil and:[backed ~~ false]) ifTrue:[
  1344     (backed notNil and:[backed ~~ false]) ifTrue:[
  1316 	device setBackingStore:backed in:drawableId
  1345         device setBackingStore:backed in:drawableId
  1317     ].
  1346     ].
  1318     saveUnder ifTrue:[
  1347     saveUnder ifTrue:[
  1319 	device setSaveUnder:true in:drawableId
  1348         device setSaveUnder:true in:drawableId
  1320     ].
  1349     ].
  1321     device setWindowClass:('Stx', self className) name:name in:drawableId.
  1350     device setWindowClass:('Stx', self className) name:name in:drawableId.
  1322 
  1351 
  1323     "Modified: 14.6.1996 / 17:14:25 / stefan"
  1352     "Modified: 14.6.1996 / 17:14:25 / stefan"
  1324     "Modified: 7.4.1997 / 11:38:22 / cg"
  1353     "Modified: 20.8.1997 / 14:18:59 / cg"
  1325 !
  1354 !
  1326 
  1355 
  1327 postRealize
  1356 postRealize
  1328     "postRealize actions - tell the application (if any)."
  1357     "postRealize actions - tell the application (if any)."
  1329 
  1358 
  1370 ! !
  1399 ! !
  1371 
  1400 
  1372 !StandardSystemView class methodsFor:'documentation'!
  1401 !StandardSystemView class methodsFor:'documentation'!
  1373 
  1402 
  1374 version
  1403 version
  1375     ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.82 1997-08-15 11:03:33 cg Exp $'
  1404     ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.83 1997-08-20 17:18:15 cg Exp $'
  1376 ! !
  1405 ! !
       
  1406 StandardSystemView initialize!