Form.st
changeset 126 4fc31fd808c8
parent 118 25e775072a89
child 127 98b0725782bd
equal deleted inserted replaced
125:d74e6ab7157a 126:4fc31fd808c8
    14        instanceVariableNames:'depth localColorMap offset data fileName'
    14        instanceVariableNames:'depth localColorMap offset data fileName'
    15        classVariableNames:'VeryLightGreyForm LightGreyForm GreyForm 
    15        classVariableNames:'VeryLightGreyForm LightGreyForm GreyForm 
    16 			   DarkGreyForm VeryDarkGreyForm
    16 			   DarkGreyForm VeryDarkGreyForm
    17 
    17 
    18 			   AdditionalBitmapDirectoryNames
    18 			   AdditionalBitmapDirectoryNames
    19 			   BlackAndWhiteColorMap DitherPatternArray
    19 			   BlackAndWhiteColorMap DitherPatternArray'
    20 			   Lobby'
       
    21        poolDictionaries:''
    20        poolDictionaries:''
    22        category:'Graphics-Display Objects'
    21        category:'Graphics-Display Objects'
    23 !
    22 !
    24 
    23 
    25 Form comment:'
    24 Form comment:'
    26 COPYRIGHT (c) 1989 by Claus Gittinger
    25 COPYRIGHT (c) 1989 by Claus Gittinger
    27 	      All Rights Reserved
    26 	      All Rights Reserved
    28 
    27 
    29 $Header: /cvs/stx/stx/libview/Form.st,v 1.21 1995-03-18 05:11:05 claus Exp $
    28 $Header: /cvs/stx/stx/libview/Form.st,v 1.22 1995-03-29 10:49:42 claus Exp $
    30 '!
    29 '!
    31 
    30 
    32 !Form class methodsFor:'documentation'!
    31 !Form class methodsFor:'documentation'!
    33 
    32 
    34 copyright
    33 copyright
    45 "
    44 "
    46 !
    45 !
    47 
    46 
    48 version
    47 version
    49 "
    48 "
    50 $Header: /cvs/stx/stx/libview/Form.st,v 1.21 1995-03-18 05:11:05 claus Exp $
    49 $Header: /cvs/stx/stx/libview/Form.st,v 1.22 1995-03-29 10:49:42 claus Exp $
    51 "
    50 "
    52 !
    51 !
    53 
    52 
    54 documentation
    53 documentation
    55 "
    54 "
    60 ! !
    59 ! !
    61 
    60 
    62 !Form class methodsFor:'initialization'!
    61 !Form class methodsFor:'initialization'!
    63 
    62 
    64 initialize
    63 initialize
    65     "initialize set of dictionaries to look for bitmaps
    64     "initialize set of dictionaries to look for bitmaps"
    66      and Lobby to keep track of dead forms"
       
    67 
    65 
    68     AdditionalBitmapDirectoryNames isNil ifTrue:[
    66     AdditionalBitmapDirectoryNames isNil ifTrue:[
    69 	super initialize.
    67 	super initialize.
    70 
    68 
    71 	AdditionalBitmapDirectoryNames := #('/usr/lib/X11/bitmaps').
    69 	AdditionalBitmapDirectoryNames := #('/usr/lib/X11/bitmaps').
    72     
    70     
    73 	Lobby := Registry new.
       
    74 
       
    75 	"want to be informed when returning from snapshot"
    71 	"want to be informed when returning from snapshot"
    76 	ObjectMemory addDependent:self.
    72 	ObjectMemory addDependent:self.
    77     ]
    73     ]
    78 !
    74 !
    79 
    75 
    81     "recreate all forms on aDevice; called by Workstation, to
    77     "recreate all forms on aDevice; called by Workstation, to
    82      have all background bitmaps at hand, when views are restored"
    78      have all background bitmaps at hand, when views are restored"
    83 
    79 
    84     Lobby do:[:aForm |
    80     Lobby do:[:aForm |
    85 	(aForm device == aDevice) ifTrue:[
    81 	(aForm device == aDevice) ifTrue:[
    86 	    "now, try to recreate it"
    82 	    (aForm class == self) ifTrue:[
    87 	    aForm recreate.
    83 		"now, try to recreate it"
       
    84 		aForm recreate.
       
    85 	    ]
    88 	]
    86 	]
    89     ]
    87     ]
    90 !
    88 !
    91 
    89 
    92 update:something
    90 update:something
    93     "sent just before snapOut and just after a snapIn"
    91     "sent just before snapOut and just after a snapIn"
    94 
    92 
    95     (something == #save) ifTrue:[
    93     (something == #save) ifTrue:[
    96 	"get all bits from the device into saveable arrays"
    94 	"get all bits from the device into saveable arrays"
    97 	Lobby do:[:aForm |
    95 	Lobby do:[:aForm |
    98 	    aForm getBits
    96 	    (aForm class == self) ifTrue:[
       
    97 		aForm getBits
       
    98 	    ]
    99 	]
    99 	]
   100     ].
   100     ].
   101     (something == #restarted) ifTrue:[
   101     (something == #restarted) ifTrue:[
   102 	"remove all left-over device info"
   102 	"remove all left-over device info"
   103 	Lobby do:[:aForm |
   103 	Lobby do:[:aForm |
   104 	    aForm restored.
   104 	    (aForm class == self) ifTrue:[
   105 	    Lobby changed:self
   105 		aForm restored.
       
   106 		Lobby changed:aForm 
       
   107 	    ]
   106 	]
   108 	]
   107     ]
   109     ]
   108 ! !
   110 ! !
   109 
   111 
   110 !Form methodsFor:'inspecting'!
   112 !Form methodsFor:'inspecting'!
  1379 
  1381 
  1380 initGC
  1382 initGC
  1381     "stop server from sending exposure events for Forms -
  1383     "stop server from sending exposure events for Forms -
  1382      (will fill up stream-queue on some stupid (i.e. sco) systems"
  1384      (will fill up stream-queue on some stupid (i.e. sco) systems"
  1383 
  1385 
  1384     self createGC.
  1386     super initGC.
  1385     Lobby changed:self.
  1387 "/    self createGC.
       
  1388 "/    Lobby changed:self.
  1386     self setGraphicsExposures:false
  1389     self setGraphicsExposures:false
  1387 !
  1390 !
  1388 
  1391 
  1389 recreate
  1392 recreate
  1390     "reconstruct the form after a snapin"
  1393     "reconstruct the form after a snapin"
  1425 readBinaryContentsFrom: stream manager: manager
  1428 readBinaryContentsFrom: stream manager: manager
  1426     "tell the newly restored Form about restoration"
  1429     "tell the newly restored Form about restoration"
  1427 
  1430 
  1428     super readBinaryContentsFrom: stream manager: manager.
  1431     super readBinaryContentsFrom: stream manager: manager.
  1429     self restored.
  1432     self restored.
  1430     Lobby register:self
  1433     Lobby register:self.
  1431 ! !
  1434 ! !
  1432 
  1435 
  1433 !Form methodsFor:'getting a device form'!
  1436 !Form methodsFor:'getting a device form'!
  1434 
  1437 
  1435 on:aDevice
  1438 on:aDevice
  1503     BlackAndWhiteColorMap isNil ifTrue:[
  1506     BlackAndWhiteColorMap isNil ifTrue:[
  1504 	BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
  1507 	BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
  1505     ].
  1508     ].
  1506     localColorMap := BlackAndWhiteColorMap.
  1509     localColorMap := BlackAndWhiteColorMap.
  1507     realized := true.
  1510     realized := true.
  1508     Lobby register:self
  1511     Lobby changed:self.
  1509 !
  1512 !
  1510 
  1513 
  1511 width:w height:h depth:d
  1514 width:w height:h depth:d
  1512     "actual create of an arbitrary deep form (but, must be supported by device)"
  1515     "actual create of an arbitrary deep form (but, must be supported by device)"
  1513 
  1516 
  1516     offset := 0@0.
  1519     offset := 0@0.
  1517     drawableId := device createPixmapWidth:w height:h depth:d.
  1520     drawableId := device createPixmapWidth:w height:h depth:d.
  1518     drawableId isNil ifTrue:[^ nil].
  1521     drawableId isNil ifTrue:[^ nil].
  1519     realized := true.
  1522     realized := true.
  1520     depth := d.
  1523     depth := d.
  1521     Lobby register:self
  1524     Lobby changed:self.
  1522 !
  1525 !
  1523 
  1526 
  1524 width:w height:h fromArray:anArray
  1527 width:w height:h fromArray:anArray
  1525     "actual create of a monochrome form from array.
  1528     "actual create of a monochrome form from array.
  1526      This method is somewhat more complicated as it should be due to 
  1529      This method is somewhat more complicated as it should be due to 
  1568     BlackAndWhiteColorMap isNil ifTrue:[
  1571     BlackAndWhiteColorMap isNil ifTrue:[
  1569 	BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
  1572 	BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
  1570     ].
  1573     ].
  1571     localColorMap := BlackAndWhiteColorMap.
  1574     localColorMap := BlackAndWhiteColorMap.
  1572     realized := true.
  1575     realized := true.
  1573     Lobby register:self
  1576     Lobby changed:self.
  1574 !
  1577 !
  1575 
  1578 
  1576 width:w height:h offset:offs fromArray:anArray
  1579 width:w height:h offset:offs fromArray:anArray
  1577     "actual create of a monochrome form from array"
  1580     "actual create of a monochrome form from array"
  1578 
  1581 
  1595 	realized := true.
  1598 	realized := true.
  1596 	BlackAndWhiteColorMap isNil ifTrue:[
  1599 	BlackAndWhiteColorMap isNil ifTrue:[
  1597 	    BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
  1600 	    BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
  1598 	].
  1601 	].
  1599 	localColorMap := BlackAndWhiteColorMap.
  1602 	localColorMap := BlackAndWhiteColorMap.
  1600 	Lobby register:self.
  1603 	Lobby changed:self.
  1601 	^ self
  1604 	^ self
  1602     ].
  1605     ].
  1603     ^ nil
  1606     ^ nil
  1604 !
  1607 !
  1605 
  1608