home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / DTS.Lib / ViewHierarchy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-02  |  27.4 KB  |  1,032 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:     DTS.Lib
  5. ** File:        viewhierarchy.c
  6. ** Written by:  Eric Soldan
  7. **
  8. ** Copyright © 1990-1993 Apple Computer, Inc.
  9. ** All rights reserved.
  10. */
  11.  
  12. /* You may incorporate this sample code into your applications without
  13. ** restriction, though the sample code has been provided "AS IS" and the
  14. ** responsibility for its operation is 100% yours.  However, what you are
  15. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  16. ** after having made changes. If you're going to re-distribute the source,
  17. ** we require that you make it clear in the source that the code was
  18. ** descended from Apple Sample Code, but that you've made changes. */
  19.  
  20.  
  21.  
  22. /*****************************************************************************/
  23.  
  24.  
  25.  
  26. #include "DTS.Lib2.h"
  27. #include "DTS.Lib.protos.h"
  28.  
  29. #ifndef __CTLHANDLER__
  30. #include "CtlHandler.h"
  31. #endif
  32.  
  33. #ifndef __ERRORS__
  34. #include <Errors.h>
  35. #endif
  36.  
  37. #ifndef __FONTS__
  38. #include <Fonts.h>
  39. #endif
  40.  
  41. #ifndef __LISTCONTROL__
  42. #include "ListControl.h"
  43. #endif
  44.  
  45. #ifndef __RESOURCES__
  46. #include <Resources.h>
  47. #endif
  48.  
  49. #ifndef THINK_C
  50. #ifndef __STRINGS__
  51. #include <Strings.h>
  52. #endif
  53. #endif
  54.  
  55. #ifndef __TEXTEDITCONTROL__
  56. #include "TextEditControl.h"
  57. #endif
  58.  
  59.  
  60.  
  61. /*****************************************************************************/
  62.  
  63.  
  64.  
  65. #ifdef powerc
  66. #pragma options align=mac68k
  67. #endif
  68. typedef struct ViewHierFileTypeRec {
  69.     FileStateRec    fileState;
  70.     ConnectRec        connect;
  71.     ViewDoc            vh;
  72. } ViewHierFileTypeRec;
  73. #ifdef powerc
  74. #pragma options align=reset
  75. #endif
  76.  
  77.  
  78. extern short    gTECtl;
  79. extern short    gListCtl;
  80.  
  81. extern short            gPrintPage;            /* Non-zero means we are printing. */
  82. extern TreeObjProcPtr    gTreeObjMethods[];
  83. extern Cursor            *gCursorPtr;
  84. extern TreeObjHndl        gWindowFormats;
  85.  
  86. static void        VHContentClick(WindowPtr window, EventRecord *event, Boolean firstClick);
  87. static Boolean    VHContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough);
  88. static OSErr    VHImageDocument(FileRecHndl frHndl);
  89. static OSErr    VHInitContent(FileRecHndl frHndl, WindowPtr window);
  90. static Boolean    VHDisplayFilter(TEHandle teHndl, EventRecord *event, short *handled);
  91. static void        VHNewView(FileRecHndl frHndl, char *newText, short newTextLen, Boolean updatePList);
  92. static OSErr    VHUpdateInfo(FileRecHndl frHndl, Boolean updatePList);
  93. static Boolean    VHWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt);
  94.  
  95.  
  96.  
  97. /*****************************************************************************/
  98. /*****************************************************************************/
  99.  
  100.  
  101.  
  102. /* This is called when a mouse-down event occurs in the content of a window.
  103. ** Other applications might want to call FindControl, TEClick, etc., to
  104. ** further process the click. */
  105.  
  106. #pragma segment Window
  107. void    VHContentClick(WindowPtr window, EventRecord *event, Boolean firstClick)
  108. {
  109. #ifndef __MWERKS__
  110. #pragma unused (firstClick)
  111. #endif
  112.  
  113.     FileRecHndl        frHndl;
  114.     ControlHandle    ctl;
  115.     short            ctlNum, action, len, selStart;
  116.     ListHandle        plist, clist;
  117.     TEHandle        te, display;
  118.     char            newText[33];
  119.     Point            cell;
  120.  
  121.     frHndl = (FileRecHndl)GetWRefCon(window);
  122.  
  123.     ctlNum = IsCtlEvent(window, event, &ctl, &action);
  124.     switch (ctlNum) {
  125.         case 101:
  126.             display = (*frHndl)->d.vh.display;
  127.             te = CTEFindActive(window);
  128.             if (!te)
  129.                 te = display;
  130.             ctl = CTEViewFromTE(te);
  131.             if (te == display) {
  132.                 CTEActivate(true, te);
  133.                 CLActivate(false, CLFindActive(window));
  134.                 CTESetSelect(0, (*te)->teLength, display);
  135.             }
  136.             len = (*te)->selEnd - (selStart = (*te)->selStart);
  137.             if (len > 32)
  138.                 len = 32;
  139.             BlockMove(*((*te)->hText) + selStart, newText, len);
  140.             VHNewView(frHndl, newText, len, true);
  141.             break;
  142.         case 102:
  143.             if (action == 1) {
  144.                 plist = (*frHndl)->d.vh.plist;
  145.                 cell  = LLastClick(plist);
  146.                 len   = 8;
  147.                 LGetCell(newText, &len, cell, plist);
  148.                 VHNewView(frHndl, newText, len, false);
  149.             }
  150.             break;
  151.         case 103:
  152.             if (action == 1) {
  153.                 clist = (*frHndl)->d.vh.clist;
  154.                 cell  = LLastClick(clist);
  155.                 len   = 8;
  156.                 LGetCell(newText, &len, cell, clist);
  157.                 VHNewView(frHndl, newText, len, true);
  158.             }
  159.             break;
  160.     }
  161. }
  162.  
  163.  
  164.  
  165. /*****************************************************************************/
  166.  
  167.  
  168.  
  169. /* This is called when a key event occurs and it is determined that it isn't
  170. ** a menu key. */
  171.  
  172. #pragma segment Window
  173. Boolean    VHContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough)
  174. {
  175. #ifndef __MWERKS__
  176. #pragma unused (passThrough)
  177. #endif
  178.  
  179.     FileRecHndl        frHndl;
  180.     char            key;
  181.     ControlHandle    ctl;
  182.     short            action, selStart, len;
  183.     TEHandle        te, display;
  184.     char            newText[33];
  185.     TreeObjHndl        pobj, cobj;
  186.  
  187.     frHndl = (FileRecHndl)GetWRefCon(window);
  188.     key = event->message & charCodeMask;
  189.  
  190.     if ((key == chEnter) || (key == chReturn)) {
  191.         SelectButton(ctl = (*frHndl)->d.vh.newView);
  192.         display = (*frHndl)->d.vh.display;
  193.         te = CTEFindActive(window);
  194.         if (!te)
  195.             te = display;
  196.         ctl = CTEViewFromTE(te);
  197.         if (te == display) {
  198.             CTEActivate(true, te);
  199.             CLActivate(false, CLFindActive(window));
  200.             CTESetSelect(0, (*te)->teLength, display);
  201.         }
  202.         len = (*te)->selEnd - (selStart = (*te)->selStart);
  203.         if (len > 32)
  204.             len = 32;
  205.         BlockMove(*((*te)->hText) + selStart, newText, len);
  206.         VHNewView(frHndl, newText, len, true);
  207.         return(true);
  208.     }
  209.     if (key == chFwdDelete) {
  210.         if (event->modifiers & optionKey) {
  211.             cobj = (*frHndl)->d.vh.root;
  212.             pobj = (*cobj)->parent;
  213.             if (pobj) {
  214.                 DisposeChild(NO_EDIT, pobj, GetChildNum(cobj));
  215.                 ccpypadhex(newText, 0, 8, 8, (long)pobj);
  216.                 VHNewView(frHndl, newText, 8, true);
  217.             }
  218.         }
  219.     }
  220.  
  221.     return(IsCtlEvent(window, event, &ctl, &action));
  222. }
  223.  
  224.  
  225.  
  226. /*****************************************************************************/
  227.  
  228.  
  229.  
  230. /* Image the document into the current port. */
  231.  
  232. #pragma segment Window
  233. OSErr    VHImageDocument(FileRecHndl frHndl)
  234. {
  235. #ifndef __MWERKS__
  236. #pragma unused (frHndl)
  237. #endif
  238.  
  239.     WindowPtr        curPort;
  240.  
  241.     GetPort(&curPort);
  242.  
  243.     if (!gPrintPage) {                                        /* If not printing... */
  244.         DoDrawControls(curPort, false);                        /* Draw the content controls. */
  245.         OutlineControl((*frHndl)->d.vh.newView);
  246.     }
  247.     else {
  248.         gPrintPage = 0;
  249.     }
  250.  
  251.     return(noErr);
  252. }
  253.  
  254.  
  255.  
  256. /*****************************************************************************/
  257.  
  258.  
  259.  
  260. /* This function does the remaining window initialization. */
  261.  
  262. #pragma segment Window
  263. OSErr    VHInitContent(FileRecHndl frHndl, WindowPtr window)
  264. {
  265.     FileRecPtr        frPtr;
  266.     FileRecHndl        refFrHndl;
  267.     WindowPtr        oldPort;
  268.     ControlHandle    ctl;
  269.     TEHandle        dump, display;
  270.     ListHandle        plist, clist;
  271.     ControlHandle    newView;
  272.     OSErr            err;
  273.  
  274.     GetPort(&oldPort);
  275.     SetPort(window);
  276.  
  277.     err = AddControlSet(window, (*frHndl)->fileState.sfType, kwStandardVis, 0, 0, nil);
  278.     if (err) return(err);
  279.  
  280.     CNum2Ctl(window, 100, &ctl);
  281.     dump = (TEHandle)GetControlReference(ctl);
  282.  
  283.     CNum2Ctl(window, 101, &ctl);
  284.     display = (TEHandle)GetControlReference(ctl);
  285.     CTESetKeyFilter(display, VHDisplayFilter);
  286.  
  287.     CNum2Ctl(window, 102, &ctl);
  288.     plist = (ListHandle)GetControlReference(ctl);
  289.  
  290.     CNum2Ctl(window, 103, &ctl);
  291.     clist = (ListHandle)GetControlReference(ctl);
  292.  
  293.     CNum2Ctl(window, 104, &newView);
  294.  
  295.     frPtr = *frHndl;
  296.     frPtr->d.vh.dump    = dump;
  297.     frPtr->d.vh.display = display;
  298.     frPtr->d.vh.plist   = plist;
  299.     frPtr->d.vh.clist   = clist;
  300.     frPtr->d.vh.newView = newView;
  301.  
  302.     refFrHndl = mDerefRoot(frPtr->d.vh.root)->frHndl;
  303.     NewWindowTitle(window, (*refFrHndl)->fileState.fss.name);
  304.     VHUpdateInfo(frHndl, true);
  305.  
  306.     SetPort(oldPort);
  307.     return(noErr);
  308. }
  309.  
  310.  
  311.  
  312. /*****************************************************************************/
  313.  
  314.  
  315.  
  316. #pragma segment Window
  317. static Boolean    VHWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt)
  318. {
  319. #ifndef __MWERKS__
  320. #pragma unused (frHndl, window, globalPt)
  321. #endif
  322.  
  323.     SetCursor(gCursorPtr = &qd.arrow);
  324.     return(true);
  325. }
  326.  
  327.  
  328.  
  329. /*****************************************************************************/
  330.  
  331.  
  332.  
  333. #pragma segment Window
  334. Boolean    VHDisplayFilter(TEHandle teHndl, EventRecord *event, short *handled)
  335. {
  336. #ifndef __MWERKS__
  337. #pragma unused (teHndl, handled)
  338. #endif
  339.     char    key;
  340.     short    arrowKey;
  341.  
  342.     key = event->message & charCodeMask;
  343.     arrowKey = ((key >= chLeft) && (key <= chDown));
  344.     if (
  345.         (arrowKey) ||
  346.         (key == chBackspace) ||
  347.         (key == chTab) ||
  348.         ((key >= '0') && (key <= '9')) ||
  349.         ((key >= 'A') && (key <= 'F')) ||
  350.         ((key >= 'a') && (key <= 'f'))
  351.     ) {
  352.         return(false);
  353.     }
  354.  
  355.     return(true);
  356. }
  357.  
  358.  
  359.  
  360. /*****************************************************************************/
  361.  
  362.  
  363.  
  364. /* This function adds the application's controls to a window. */
  365.  
  366. #pragma segment Window
  367. void    VHNewView(FileRecHndl frHndl, char *newText, short newTextLen, Boolean updatePList)
  368. {
  369.     TEHandle    te;
  370.     short        len, i;
  371.     long        newHndl;
  372.     char        workText[33];
  373.  
  374.     if (!newText) {
  375.         newText    = workText;
  376.         newTextLen = 0;
  377.     }
  378.     if (!(len = newTextLen)) {
  379.         te = (*frHndl)->d.vh.display;
  380.         BlockMove(*((*te)->hText), newText, len = (*te)->teLength);
  381.     }
  382.  
  383.     for (newHndl = 0, i = 0; i < len; ++i) {
  384.         if ((newText[i] >= '0') && (newText[i] <= '9')) {
  385.             newHndl *= 16;
  386.             newHndl += (newText[i] - '0');
  387.             continue;
  388.         }
  389.         if ((newText[i] >= 'a') && (newText[i] <= 'f'))
  390.             newText[i] -= 32;
  391.         if ((newText[i] >= 'A') && (newText[i] <= 'F')) {
  392.             newHndl *= 16;
  393.             newHndl += (newText[i] - 'A' + 10);
  394.         }
  395.     }
  396.  
  397.     if (newHndl) {
  398.         GetHandleSize((Handle)newHndl);
  399.         if (!MemError()) {
  400.             (*frHndl)->d.vh.root = (TreeObjHndl)newHndl;
  401.             VHUpdateInfo(frHndl, updatePList);
  402.         }
  403.         else SysBeep(1);
  404.     }
  405. }
  406.  
  407.  
  408.  
  409. /*****************************************************************************/
  410.  
  411.  
  412.  
  413. /* This function adds the application's controls to a window. */
  414.  
  415. #pragma segment Window
  416. OSErr    VHUpdateInfo(FileRecHndl frHndl, Boolean updatePList)
  417. {
  418.     WindowPtr        oldPort;
  419.     TreeObjHndl        root, chndl, phndl;
  420.     TEHandle        dump;
  421.     ListHandle        plist, clist;
  422.     Handle            text;
  423.     char            *cptr, *kcptr;
  424.     long            dataSize, x, v;
  425.     short            *dptr, cnum, depth, ctype;
  426.     Point            cell;
  427.     char            ctext[32], ptext[32];
  428.     RgnHandle        rgn;
  429.     Boolean            customFormat;
  430.     TreeObjProcPtr    proc;
  431.     VHFormatData    cf;
  432.  
  433.     root  = (*frHndl)->d.vh.root;
  434.     dump  = (*frHndl)->d.vh.dump;
  435.     plist = (*frHndl)->d.vh.plist;
  436.     clist = (*frHndl)->d.vh.clist;
  437.  
  438.     DoNumberTree(root);
  439.  
  440.     text = NewHandle(32767);
  441.     if (!text)
  442.         return(MemError());
  443.  
  444.     GetPort(&oldPort);
  445.     SetPort((*frHndl)->fileState.window);
  446.  
  447.     HLock(text);
  448.     cptr = kcptr = StripAddress(*text);
  449.  
  450.     ccpy      (cptr, "$");
  451.     ccatpadhex(cptr, '0', 8, 8, (long)root);
  452.     ccatchr   (cptr, 13, 2);
  453.  
  454.     ccat      (cptr, "$00:        type = $");
  455.     ccatpadhex(cptr, '0', 4, 4, ctype = (*root)->type);
  456.     ccatchr   (cptr, 13, 1);
  457.  
  458.     ccat      (cptr, "$02: numChildren = $");
  459.     ccatpadhex(cptr, '0', 4, 4, (*root)->numChildren);
  460.     ccatchr   (cptr, 13, 1);
  461.  
  462.     ccat      (cptr, "$04:    dataSize = $");
  463.     ccatpadhex(cptr, '0', 8, 8, dataSize = (*root)->dataSize);
  464.     ccatchr   (cptr, 13, 1);
  465.  
  466.     ccat      (cptr, "$08:      treeID = $");
  467.     ccatpadhex(cptr, '0', 8, 8, (*root)->treeID);
  468.     ccatchr   (cptr, 13, 1);
  469.  
  470.     ccat      (cptr, "$0C:      parent = $");
  471.     ccatpadhex(cptr, '0', 8, 8, (long)(*root)->parent);
  472.  
  473.     customFormat = false;
  474.     proc = gTreeObjMethods[ctype];
  475.     if (proc) {                                /* If this object type has a proc...   */
  476.         cptr     += clen(cptr);
  477.         cf.text   = text;
  478.         cf.header = kcptr;
  479.         cf.data   = cptr;
  480.         customFormat = (*proc)(root, VHMESSAGE, (long)&cf);
  481.         HLock(text);
  482.         cptr = kcptr = StripAddress(*text);
  483.         cptr += clen(cptr);
  484.     }
  485.  
  486.     if (!customFormat) {
  487.         dptr = (short *)GetDataPtr(root);
  488.         for (x = 0; (cptr += clen(cptr)), (x < dataSize); x += sizeof(short)) {
  489.             v = *dptr++;
  490.             v &= 0x0000FFFF;
  491.             if ((dataSize - x) == 1) {
  492.                 v >>= 8;
  493.                 v  &= 0x00FF;
  494.             }
  495.             if (!(x & 0x3F)) {
  496.                 ccatchr   (cptr, 13, 2);
  497.                 ccat      (cptr, "$");
  498.                 ccatpadhex(cptr, '0', 8, 8, x + sizeof(TreeObj));
  499.                 ccat      (cptr, ":");
  500.             }
  501.             if (!(x & 0x0F)) {
  502.                 ccatchr(cptr, 13, 1);
  503.                 ccat   (cptr, " ");
  504.             }
  505.             ccat   (cptr, " ");
  506.             if ((dataSize - x) == 1)
  507.                 ccatpadhex(cptr, '0', 2, 2, v);
  508.             else
  509.                 ccatpadhex(cptr, '0', 4, 4, v);
  510.             if ((cptr - kcptr) > 32000) break;
  511.         }
  512.     }
  513.  
  514.     HUnlock(text);
  515.     SetHandleSize(text, cptr - kcptr);
  516.  
  517.     UseControlStyle(CTEViewFromTE(dump));
  518.     DisposeHandle(CTESwapText(dump, text, nil, true));
  519.     UseControlStyle(nil);
  520.  
  521.     UseControlStyle(CLViewFromList(clist));
  522.     LDelRow(0, 0, clist);
  523.     LSetDrawingMode(false, clist);
  524.     cell.h = cell.v = 0;
  525.     for (cnum = (*root)->numChildren; cnum;) {
  526.         chndl = GetChildHndl(root, --cnum);
  527.         ccpypadhex(ctext, '0', 8, 8, (long)chndl);
  528.         LAddRow(1, 0, clist);
  529.         LSetCell(ctext, 8, cell, clist);
  530.     }
  531.     LSetDrawingMode(true, clist);
  532.     rgn = NewRgn();
  533.     GetClip(rgn);
  534.     LUpdate(rgn, clist);
  535.     DisposeRgn(rgn);
  536.     UseControlStyle(nil);
  537.  
  538.     UseControlStyle(CLViewFromList(plist));
  539.     if (updatePList) {
  540.         LDelRow(0, 0, plist);
  541.         LSetDrawingMode(false, plist);
  542.         cell.h = cell.v = 0;
  543.         for (depth = 0, phndl = root; phndl; phndl = (*phndl)->parent, ++depth) {
  544.             ccpypadhex(ptext, '0', 8, 8, (long)phndl);
  545.             LAddRow(1, 0, plist);
  546.             LSetCell(ptext, 8, cell, plist);
  547.         }
  548.         cell.v = depth - 1;
  549.         LSetSelect(true, cell, plist);
  550.         LAutoScroll(plist);
  551.         LSetDrawingMode(true, plist);
  552.         rgn = NewRgn();
  553.         GetClip(rgn);
  554.         LUpdate(rgn, plist);
  555.         DisposeRgn(rgn);
  556.     }
  557.     else LAutoScroll(plist);
  558.     UseControlStyle(nil);
  559.  
  560.     SetPort(oldPort);
  561.     return(noErr);
  562. }
  563.  
  564.  
  565.  
  566. /*****************************************************************************/
  567. /*****************************************************************************/
  568.  
  569.  
  570.  
  571. #pragma segment Window
  572. OSErr    VHInitDocument(FileRecHndl frHndl)
  573. {
  574.     FileRecPtr    frPtr;
  575.     FileRecHndl    refFrHndl;
  576.     WindowPtr    window;
  577.  
  578.     frPtr = *frHndl;
  579.     if (!gWindowFormats) {
  580.         frPtr->fileState.windowID   = rVHWindow;
  581.         frPtr->fileState.attributes = kwVHAppWindow;
  582.     }
  583.     frPtr->fileState.calcFrameRgnProc        = nil;
  584.     frPtr->fileState.contentClickProc        = VHContentClick;
  585.     frPtr->fileState.contentKeyProc          = VHContentKey;
  586.     frPtr->fileState.drawFrameProc           = nil;
  587.     frPtr->fileState.freeDocumentProc        = nil;
  588.     frPtr->fileState.freeWindowProc          = nil;
  589.     frPtr->fileState.imageProc               = VHImageDocument;
  590.     frPtr->fileState.initContentProc         = VHInitContent;
  591.     frPtr->fileState.readDocumentProc        = nil;
  592.     frPtr->fileState.readDocumentHeaderProc  = nil;
  593.     frPtr->fileState.resizeContentProc       = nil;
  594.     frPtr->fileState.scrollFrameProc         = nil;
  595.     frPtr->fileState.undoFixupProc           = nil;
  596.     frPtr->fileState.windowCursorProc        = VHWindowCursor;
  597.     frPtr->fileState.writeDocumentProc       = nil;
  598.     frPtr->fileState.writeDocumentHeaderProc = nil;
  599.         /* View Hierarchy method declarations. */
  600.  
  601.     /* Document-specific fields are already initialized to 0, so we do nothing. */
  602.  
  603.     for (window = nil; (window = GetNextWindow(window, 0)) != nil;) {
  604.         if (!((WindowPeek)window)->visible) continue;
  605.         refFrHndl = (FileRecHndl)GetWRefCon(window);
  606.         if (refFrHndl) {
  607.             if ((*refFrHndl)->fileState.defaultDoc) {
  608.                 (*frHndl)->d.vh.root = (*refFrHndl)->d.vh.root;
  609.                     /* This view hierarchy window, which isn't created yet, will reference
  610.                     ** the data in the topmost window that uses the default document
  611.                     ** architecture.  As the view hierarchy window is only for debugging
  612.                     ** purposes, there is no prevision to guarantee that the data being
  613.                     ** pointed to will continue to exist or continue to be valid.
  614.                     ** The document that this references could be closed, and therefore
  615.                     ** the reference would point to non-existent data.  (You are warned.) */
  616.                 return(noErr);
  617.             }
  618.         }
  619.     } 
  620.  
  621.     return(memFullErr);
  622.         /* Memory really isn't full.  We just need to pass back an error so that
  623.         ** the application knows that the view hierarchy document wasn't successfully
  624.         ** created.  It wasn't successfull created because it couldn't find any documents
  625.         ** that use the document hierarchy.  This really shouldn't occur, as the application
  626.         ** shouldn't have the menu option available for the view hierarchy window if there
  627.         ** is nothing to view.  However, since the view hierarchy window is just for
  628.         ** debugging, it seems annoying to demand that the application set the state of
  629.         ** the menu item correctly.  Returning any error here should be enough for the
  630.         ** application to be graceful. */
  631. }
  632.  
  633.  
  634.  
  635. /*****************************************************************************/
  636.  
  637.  
  638.  
  639. #pragma segment Window
  640. long    VHFileTypeSize(void)
  641. {
  642.     return(sizeof(ViewHierFileTypeRec));
  643. }
  644.  
  645.  
  646.  
  647. /*****************************************************************************/
  648.  
  649.  
  650.  
  651. #pragma segment Window
  652. void    VHRootInfo(TreeObjHndl root, char *cptr)
  653. {
  654.     ccat      (cptr, "$10: TRootObj:");
  655.     ccatchr   (cptr, 13, 1);
  656.     ccat      (cptr, "  $00: undo        = $");
  657.     ccatpadhex(cptr, '0', 8, 8, (long)mDerefUndo(root)->root);
  658.     ccatchr   (cptr, 13, 1);
  659.     ccat      (cptr, "  $04: frHndl      = $");
  660.     ccatpadhex(cptr, '0', 8, 8, (long)mDerefUndo(root)->frHndl);
  661.     ccatchr   (cptr, 13, 1);
  662. }
  663.  
  664.  
  665.  
  666. /*****************************************************************************/
  667.  
  668.  
  669.  
  670. #pragma segment Window
  671. void    VHFileRecInfo(TreeObjHndl root, char *cptr)
  672. {
  673.     FileRecHndl    frHndl;
  674.     Str255        str;
  675.     char        hstate;
  676.     Rect        rct;
  677.     long        offset;
  678.  
  679.     frHndl = mDerefRoot(root)->frHndl;
  680.     hstate = LockHandleHigh((Handle)frHndl);
  681.  
  682.     ccat   (cptr, "(*frHndl)->fileState:");
  683.     ccatchr(cptr, 13, 1);
  684.     ccat   (cptr, "  sfType                  = '");
  685.     BlockMove(&(*frHndl)->fileState.sfType, str, sizeof(long));
  686.     str[sizeof(long)] = 0;
  687.     ccat   (cptr, (char *)str);
  688.     ccat   (cptr, "'");
  689.     ccatchr(cptr, 13, 1);
  690.  
  691.     ccat   (cptr, "  defaultDoc              = ");
  692.     ccatdec(cptr, (*frHndl)->fileState.defaultDoc);
  693.     ccatchr(cptr, 13, 1);
  694.  
  695.     ccat      (cptr, "  movie                   = $");
  696.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.movie);
  697.     ccatchr   (cptr, 13, 1);
  698.  
  699.     ccat   (cptr, "  movieResID              = ");
  700.     ccatdec(cptr, (*frHndl)->fileState.movieResID);
  701.     ccatchr(cptr, 13, 1);
  702.  
  703.     ccat      (cptr, "  movieFlags              = $");
  704.     ccatpadhex(cptr, '0', 4, 4, (*frHndl)->fileState.movieFlags);
  705.     ccatchr   (cptr, 13, 1);
  706.  
  707.     ccat   (cptr, "  movieDataRefWasChanged  = ");
  708.     ccatdec(cptr, (*frHndl)->fileState.movieDataRefWasChanged);
  709.     ccatchr(cptr, 13, 1);
  710.  
  711.     ccat   (cptr, "  docDirty                = ");
  712.     ccatdec(cptr, (*frHndl)->fileState.docDirty);
  713.     ccatchr(cptr, 13, 1);
  714.  
  715.     ccat   (cptr, "  modNum                  = ");
  716.     ccatdec(cptr, (*frHndl)->fileState.modNum);
  717.     ccatchr(cptr, 13, 1);
  718.  
  719.     ccat   (cptr, "  modTick                 = ");
  720.     ccatdec(cptr, (*frHndl)->fileState.modTick);
  721.     ccatchr(cptr, 13, 1);
  722.  
  723.     ccat   (cptr, "  readOnly                = ");
  724.     ccatdec(cptr, (*frHndl)->fileState.readOnly);
  725.     ccatchr(cptr, 13, 1);
  726.  
  727.     ccat   (cptr, "  refNum                  = ");
  728.     ccatdec(cptr, (*frHndl)->fileState.refNum);
  729.     ccatchr(cptr, 13, 1);
  730.  
  731.     ccat   (cptr, "  resRefNum               = ");
  732.     ccatdec(cptr, (*frHndl)->fileState.resRefNum);
  733.     ccatchr(cptr, 13, 1);
  734.  
  735.     ccat   (cptr, "  fss.vRefNum             = ");
  736.     ccatdec(cptr, (*frHndl)->fileState.fss.vRefNum);
  737.     ccatchr(cptr, 13, 1);
  738.  
  739.     ccat      (cptr, "  fss.parID               = $");
  740.     ccatpadhex(cptr, '0', 8, 8, (*frHndl)->fileState.fss.parID);
  741.     ccatchr   (cptr, 13, 1);
  742.  
  743.     ccat   (cptr, "  fss.name                = ");
  744.     pcpy   (str, (*frHndl)->fileState.fss.name);
  745.     p2c    (str);
  746.     ccat   (cptr, (char *)str);
  747.     ccatchr(cptr, 13, 1);
  748.  
  749.     ccat   (cptr, "  windowID                = ");
  750.     ccatnum(cptr, (*frHndl)->fileState.windowID, 10);
  751.     ccatchr(cptr, 13, 1);
  752.  
  753.     ccat      (cptr, "  window                  = $");
  754.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.window);
  755.     ccatchr   (cptr, 13, 1);
  756.  
  757.     cptr += clen(cptr);
  758.  
  759.     ccat      (cptr, "  getDocWindow            = $");
  760.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.getDocWindow);
  761.     ccatchr   (cptr, 13, 1);
  762.  
  763.     ccat      (cptr, "  calcFrameRgnProc        = $");
  764.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.calcFrameRgnProc);
  765.     ccatchr   (cptr, 13, 1);
  766.  
  767.     ccat      (cptr, "  contentClickProc        = $");
  768.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.contentClickProc);
  769.     ccatchr   (cptr, 13, 1);
  770.  
  771.     ccat      (cptr, "  contentKeyProc          = $");
  772.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.contentKeyProc);
  773.     ccatchr   (cptr, 13, 1);
  774.  
  775.     ccat      (cptr, "  drawFrameProc           = $");
  776.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.drawFrameProc);
  777.     ccatchr   (cptr, 13, 1);
  778.  
  779.     ccat      (cptr, "  freeDocumentProc        = $");
  780.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.freeDocumentProc);
  781.     ccatchr   (cptr, 13, 1);
  782.  
  783.     ccat      (cptr, "  freeWindowProc          = $");
  784.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.freeWindowProc);
  785.     ccatchr   (cptr, 13, 1);
  786.  
  787.     ccat      (cptr, "  imageProc               = $");
  788.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.imageProc);
  789.     ccatchr   (cptr, 13, 1);
  790.  
  791.     ccat      (cptr, "  initContentProc         = $");
  792.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.initContentProc);
  793.     ccatchr   (cptr, 13, 1);
  794.  
  795.     ccat      (cptr, "  readDocumentProc        = $");
  796.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.readDocumentProc);
  797.     ccatchr   (cptr, 13, 1);
  798.  
  799.     ccat      (cptr, "  readDocumentHeaderProc  = $");
  800.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.readDocumentHeaderProc);
  801.     ccatchr   (cptr, 13, 1);
  802.  
  803.     ccat      (cptr, "  resizeContentProc       = $");
  804.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.resizeContentProc);
  805.     ccatchr   (cptr, 13, 1);
  806.  
  807.     ccat      (cptr, "  scrollFrameProc         = $");
  808.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.scrollFrameProc);
  809.     ccatchr   (cptr, 13, 1);
  810.  
  811.     ccat      (cptr, "  undoFixupProc           = $");
  812.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.undoFixupProc);
  813.     ccatchr   (cptr, 13, 1);
  814.  
  815.     ccat      (cptr, "  windowCursorProc        = $");
  816.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.windowCursorProc);
  817.     ccatchr   (cptr, 13, 1);
  818.  
  819.     ccat      (cptr, "  writeDocumentProc       = $");
  820.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.writeDocumentProc);
  821.     ccatchr   (cptr, 13, 1);
  822.  
  823.     ccat      (cptr, "  writeDocumentHeaderProc = $");
  824.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.writeDocumentHeaderProc);
  825.     ccatchr   (cptr, 13, 1);
  826.  
  827.     ccat      (cptr, "  adjustMenuItemsProc     = $");
  828.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.adjustMenuItemsProc);
  829.     ccatchr   (cptr, 13, 1);
  830.  
  831.     ccat      (cptr, "  doMenuItemProc          = $");
  832.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.doMenuItemProc);
  833.     ccatchr   (cptr, 13, 1);
  834.  
  835.     cptr += clen(cptr);
  836.  
  837.     ccat      (cptr, "  attributes              = $");
  838.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.attributes);
  839.     ccatchr   (cptr, 13, 1);
  840.  
  841.     ccat   (cptr, "  windowSizeBounds        = ($");
  842.     rct = (*frHndl)->fileState.windowSizeBounds;
  843.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  844.     ccat      (cptr, ",$");
  845.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  846.     ccat      (cptr, ",");
  847.     ccatchr   (cptr, 13, 1);
  848.     ccatchr   (cptr, ' ', 29);
  849.     ccat      (cptr, "$");
  850.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  851.     ccat      (cptr, ",$");
  852.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  853.     ccat      (cptr, ")");
  854.     ccatchr   (cptr, 13, 1);
  855.  
  856.     ccat      (cptr, "  hScroll                 = $");
  857.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.hScroll);
  858.     ccatchr   (cptr, 13, 1);
  859.  
  860.     ccat      (cptr, "  vScroll                 = $");
  861.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.vScroll);
  862.     ccatchr   (cptr, 13, 1);
  863.  
  864.     ccat   (cptr, "  hScrollIndent           = ");
  865.     ccatdec(cptr, (*frHndl)->fileState.hScrollIndent);
  866.     ccatchr(cptr, 13, 1);
  867.  
  868.     ccat   (cptr, "  vScrollIndent           = ");
  869.     ccatdec(cptr, (*frHndl)->fileState.vScrollIndent);
  870.     ccatchr(cptr, 13, 1);
  871.  
  872.     ccat   (cptr, "  leftSidebar             = ");
  873.     ccatdec(cptr, (*frHndl)->fileState.leftSidebar);
  874.     ccatchr(cptr, 13, 1);
  875.  
  876.     ccat   (cptr, "  topSidebar              = ");
  877.     ccatdec(cptr, (*frHndl)->fileState.topSidebar);
  878.     ccatchr(cptr, 13, 1);
  879.  
  880.     ccat   (cptr, "  hArrowVal               = ");
  881.     ccatdec(cptr, (*frHndl)->fileState.hArrowVal);
  882.     ccatchr(cptr, 13, 1);
  883.  
  884.     ccat   (cptr, "  vArrowVal               = ");
  885.     ccatdec(cptr, (*frHndl)->fileState.vArrowVal);
  886.     ccatchr(cptr, 13, 1);
  887.  
  888.     ccat   (cptr, "  hPageVal                = ");
  889.     ccatdec(cptr, (*frHndl)->fileState.hPageVal);
  890.     ccatchr(cptr, 13, 1);
  891.  
  892.     ccat   (cptr, "  vPageVal                = ");
  893.     ccatdec(cptr, (*frHndl)->fileState.vPageVal);
  894.     ccatchr(cptr, 13, 2);
  895.  
  896.     cptr += clen(cptr);
  897.  
  898.     ccat   (cptr, "(*frHndl)->connect:");
  899.     ccatchr(cptr, 13, 1);
  900.     ccat   (cptr, "  windowTag[0]             = ");
  901.     ccatdec(cptr, (*frHndl)->connect.windowTag[0]);
  902.     ccatchr(cptr, 13, 1);
  903.  
  904.     ccat   (cptr, "  windowTag[1]             = ");
  905.     ccatdec(cptr, (*frHndl)->connect.windowTag[1]);
  906.     ccatchr(cptr, 13, 1);
  907.  
  908.     ccat   (cptr, "  connected                = ");
  909.     ccatdec(cptr, (*frHndl)->connect.connected);
  910.     ccatchr(cptr, 13, 1);
  911.  
  912.     ccat   (cptr, "  remoteLoc.descriptorType = '");
  913.     BlockMove(&(*frHndl)->connect.remoteLoc.descriptorType, str, sizeof(long));
  914.     str[sizeof(long)] = 0;
  915.     ccat   (cptr, (char *)str);
  916.     ccat   (cptr, "'");
  917.     ccatchr(cptr, 13, 1);
  918.  
  919.     ccat      (cptr, "  remoteLoc.dataHandle     = $");
  920.     ccatpadhex(cptr, '0', 8, 8, (long)(*frHndl)->connect.remoteLoc.dataHandle);
  921.     ccatchr   (cptr, 13, 1);
  922.  
  923.     ccat   (cptr, "  remoteName    = ");
  924.     pcpy   (str, (*frHndl)->connect.remoteName);
  925.     p2c    (str);
  926.     ccat   (cptr, (char *)str);
  927.     ccatchr(cptr, 13, 1);
  928.  
  929.     ccat   (cptr, "  remoteZone    = ");
  930.     pcpy   (str, (*frHndl)->connect.remoteZone);
  931.     p2c    (str);
  932.     ccat   (cptr, (char *)str);
  933.     ccatchr(cptr, 13, 1);
  934.  
  935.     ccat   (cptr, "  remoteMachine = ");
  936.     pcpy   (str, (*frHndl)->connect.remoteMachine);
  937.     p2c    (str);
  938.     ccat   (cptr, (char *)str);
  939.     ccatchr(cptr, 13, 2);
  940.  
  941.     ccat   (cptr, "  remotePath    = ");
  942.     pcpy   (str, (*frHndl)->connect.remotePath);
  943.     p2c    (str);
  944.     ccat   (cptr, (char *)str);
  945.     ccatchr(cptr, 13, 2);
  946.  
  947.     ccat   (cptr, "  remoteApp     = ");
  948.     pcpy   (str, (*frHndl)->connect.remoteApp);
  949.     p2c    (str);
  950.     ccat   (cptr, (char *)str);
  951.     ccatchr(cptr, 13, 2);
  952.  
  953.     cptr += clen(cptr);
  954.  
  955.     ccat   (cptr, "(*frHndl)->d.doc.fhInfo:");
  956.     ccatchr(cptr, 13, 1);
  957.     ccat   (cptr, "  version       = ");
  958.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.version);
  959.     ccatchr(cptr, 13, 1);
  960.  
  961.     ccat   (cptr, "  printRecValid = ");
  962.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.printRecValid);
  963.     ccatchr(cptr, 13, 1);
  964.  
  965.     ccat   (cptr, "  print         = (char *)(*frHndl) + $");
  966.     offset  = (long)StripAddress(&(*frHndl)->d.doc.fhInfo.print);
  967.     offset -= (long)StripAddress(*frHndl);
  968.     ccatpadhex(cptr, '0', 4, 4, (long)offset);
  969.     ccatchr   (cptr, 13, 1);
  970.  
  971.     ccat   (cptr, "  structureRect = ($");
  972.     rct = (*frHndl)->d.doc.fhInfo.structureRect;
  973.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  974.     ccat      (cptr, ",$");
  975.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  976.     ccat      (cptr, ",$");
  977.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  978.     ccat      (cptr, ",$");
  979.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  980.     ccat      (cptr, ")");
  981.     ccatchr   (cptr, 13, 1);
  982.  
  983.     ccat   (cptr, "  contentRect   = ($");
  984.     rct = (*frHndl)->d.doc.fhInfo.contentRect;
  985.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  986.     ccat      (cptr, ",$");
  987.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  988.     ccat      (cptr, ",$");
  989.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  990.     ccat      (cptr, ",$");
  991.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  992.     ccat      (cptr, ")");
  993.     ccatchr   (cptr, 13, 1);
  994.  
  995.     ccat   (cptr, "  stdState      = ($");
  996.     rct = (*frHndl)->d.doc.fhInfo.stdState;
  997.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  998.     ccat      (cptr, ",$");
  999.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  1000.     ccat      (cptr, ",$");
  1001.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  1002.     ccat      (cptr, ",$");
  1003.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  1004.     ccat      (cptr, ")");
  1005.     ccatchr   (cptr, 13, 1);
  1006.  
  1007.     ccat   (cptr, "  userState     = ($");
  1008.     rct = (*frHndl)->d.doc.fhInfo.userState;
  1009.     ccatpadhex(cptr, 0, 4, 4, rct.top);
  1010.     ccat      (cptr, ",$");
  1011.     ccatpadhex(cptr, 0, 4, 4, rct.left);
  1012.     ccat      (cptr, ",$");
  1013.     ccatpadhex(cptr, 0, 4, 4, rct.bottom);
  1014.     ccat      (cptr, ",$");
  1015.     ccatpadhex(cptr, 0, 4, 4, rct.right);
  1016.     ccat      (cptr, ")");
  1017.     ccatchr   (cptr, 13, 1);
  1018.  
  1019.     ccat   (cptr, "  hDocSize      = ");
  1020.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.hDocSize);
  1021.     ccatchr(cptr, 13, 1);
  1022.  
  1023.     ccat   (cptr, "  vDocSize      = ");
  1024.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.vDocSize);
  1025.     ccatchr(cptr, 13, 1);
  1026.  
  1027.     HSetState((Handle)frHndl, hstate);
  1028. }
  1029.  
  1030.  
  1031.  
  1032.