home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14649 < prev    next >
Encoding:
Text File  |  1992-08-29  |  4.3 KB  |  125 lines

  1. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!ames!agate!ucbvax!isoftfr.isoft.fr!hugues
  2. From: hugues@isoftfr.isoft.fr (Hugues Marty)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: UNofficial description of 2 Layer Manager calls
  5. Message-ID: <9208280811.AA00780@isoftfr.isoft.fr>
  6. Date: 28 Aug 92 08:11:24 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 115
  9.  
  10.  
  11.  
  12. This post contains a header and an example of how to use some calls of
  13. the UNDOCUMENTED (as long as I know) Layer Manager which comes along
  14. with System 7.  Of course, this is NOT an official document, and is
  15. here for information only. I don't have News access at the moment (I'm
  16. sending this via e-mail), so please send mail me copies if you post
  17. follow-ups.
  18.  
  19. PS: it only describes 2 calls of the LayerDispatch trap (0xA829).
  20. PPS: seems to work under 7.1 beta.
  21.  
  22. ---- C #include file following
  23.  
  24. /* Layers.h */
  25.  
  26. /* Part of the undocumented Layer Manager structures and calls
  27.  * Information found with the help of MacsBug under MacOS 7.0.
  28.  * Please note that using this information may make your mac
  29.  * explode (hey, this could be a subject for a QuickTime moovie !);
  30.  * so use at your own risks, this may break in the future,
  31.  * etc.. (usual disclaimeer).
  32.  * I only wish that Apple will document this manager in a very near
  33.  * future (let's dream...).
  34.  *
  35.  * What I found was that a layer is associated with each running
  36.  * applications (if it has a user-interface), which groups all
  37.  * windows of that application. This is how you can hide an application
  38.  * (remember 'applications' menu under system 7) and get the list of
  39.  * other applications windows. Have fun.
  40.  *
  41.  * PS : If you have more information on the Layer Manager, please
  42.  * let me know! You can join me at hugues@isoft.fr
  43.  */
  44.  
  45. #include <PasStrs.h>
  46.  
  47. // LayerRecord is similar to a WindowRecord.
  48. typedef WindowRecord LayerRecord;
  49. typedef WindowPeek LayerPtr;
  50.  
  51. // This records some information on the process which owns
  52. // the layer... Most of it is not clear (there are pointers
  53. // to other LayerRecords, to a heap zone, etc. in the unknown
  54. // parts)
  55. typedef struct {
  56.    long    unknown1;
  57.    OSType    signature;           // The process sig.
  58.    OSType    creator;             // The process creator
  59.    char      unknown2[24];
  60.    ProcessSerialNumber layerPSN;  // The process PSN
  61.    char      unknown3[40];
  62.    Handle    moreLayerInfo;       // This handle is 212 bytes sized.
  63. } LayerInfo, *LayerInfoPtr;
  64.  
  65. // This function returns a pointer to the first layer record
  66. // of the front layer on screen (front application).
  67. // Other ones are then accessed by the GetNextLayer macro.
  68. pascal LayerPtr GetFirstLayer(void)
  69.     = {0x7003, 0xA829};
  70.  
  71. // This function returns a pointer to the first window record
  72. // in the windows list of this layer.
  73. pascal WindowPtr GetFirstLayerWindow(LayerPtr aLayer)
  74.     = {0x7006, 0xa829};
  75.  
  76. // Some macros to access other information, and to hide and show a layer
  77. #define GetNextLayer(aLayer) (aLayer->nextWindow)
  78. #define GetLayerInfo(aLayer) ((LayerInfoPtr)aLayer->refCon)
  79. #define HideLayer(aLayer) HideWindow((WindowPtr)aLayer)
  80. #define ShowLayer(aLayer) ShowWindow((WindowPtr)aLayer)
  81. #define ShowHideLayer(aLayer,showFlag) ShowHide((WindowPtr)aLayer, showFlag)
  82. #define HiddenLayer(aLayer) aLayer->visible
  83.  
  84. // GetLayerName will return an address in a handle. Be aware of that.
  85. #define GetLayerName(aLayer) \
  86. (unsigned char *) ( (*GetLayerInfo(aLayer)->moreLayerInfo) + 0x38)
  87.  
  88.  
  89. /** Some sample code to show how to put the list of layers and their
  90.  ** windows names in a styled text with TextEdit.
  91.  **
  92.  
  93.   TEHandle hTE;
  94.   LayerPtr theLayer;
  95.   Str255 name;
  96.   TextStyle style;
  97.   WindowPeek window;
  98.   LayerInfoPtr info;
  99.     
  100.   hTE = TEStylNew(&windowRect, &windowRect);
  101.   theLayer = GetFirstLayer();
  102.   do {
  103.     style.tsFace = bold;
  104.     TESetStyle(doFace, &style, false, hTE);
  105.     Pstrcpy(name, GetLayerName(theLayer));
  106.     TEInsert(name+1, name[0], hTE);
  107.     TEInsert("\015", 1, hTE);
  108.     style.tsFace = 0;
  109.     TESetStyle(doFace, &style, false, hTE);
  110.     window = (WindowPeek) GetFirstLayerWindow(theLayer);
  111.     while(window) {
  112.       if (StripAddress(window->titleHandle) && StripAddress(*window->titleHandle)) {
  113.         Pstrcpy(name, *window->titleHandle);
  114.     TEInsert(name+1, name[0], hTE);
  115.     TEInsert("\015", 1, hTE);
  116.       }
  117.       window = window->nextWindow;
  118.     }
  119.   } while (theLayer = GetNextLayer(theLayer));
  120.  
  121. **  The End */
  122. --
  123. Hugues MARTY - ISoft, Chemin de Moulon, F-91190 Gif-sur-Yvette FRANCE
  124. e-mail: hugues@isoft.fr
  125.