home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / Ph 1.1.1 / PhClient / abou.c next >
Encoding:
C/C++ Source or Header  |  1991-09-30  |  3.8 KB  |  151 lines  |  [TEXT/MPS ]

  1. /*_____________________________________________________________________
  2.  
  3.       abou.c - About Box.
  4. ____________________________________________________________________*/
  5.  
  6. #pragma load "precompile"
  7. #include "rez.h"
  8. #include "utl.h"
  9. #include "abou.h"
  10. #include "glob.h"
  11. #include "edit.h"
  12. #include "oop.h"
  13.  
  14. #pragma segment abou
  15.  
  16. /*_____________________________________________________________________
  17.  
  18.     DrawAboutText - Draw About Box Text.
  19.  
  20.     Entry:    theWindow = pointer to dialog window.
  21.                 itemNo = item number of useritem.    
  22. _____________________________________________________________________*/
  23.  
  24. static pascal void DrawAboutText (WindowPtr theWindow, short itemNo)
  25.  
  26. {
  27.     short                itemType;        /* item type */
  28.     Handle            item;                /* handle to item */
  29.     Rect                box;                /* item rectangle */
  30.     short                base;                /* baseline */
  31.     char                line[80];        /* line to be drawn */
  32.     short                i;                    /* loop index */
  33.  
  34.     GetDItem(theWindow, itemNo, &itemType, &item, &box);
  35.     TextFont(FontNum);
  36.     TextSize(fontSize);
  37.     base = box.top + Ascent + Leading;
  38.     i = 1;
  39.     while (true) {
  40.         GetIndString(line, aboutStrID, i);
  41.         if (!line[0]) break;
  42.         MoveTo(box.left, base);
  43.         DrawString(line);
  44.         base += LineHeight;
  45.         i++;
  46.     }
  47.     TextFont(0);
  48.     TextSize(12);
  49. }
  50.  
  51. /*_____________________________________________________________________
  52.  
  53.     DrawStatusMsg - Draw Status Message.
  54.  
  55.     Entry:    theWindow = pointer to dialog window.
  56.                 itemNo = item number of useritem.    
  57. _____________________________________________________________________*/
  58.  
  59. static pascal void DrawStatusMsg (WindowPtr theWindow, short itemNo)
  60.  
  61. {
  62.     short                    itemType;        /* item type */
  63.     Handle                item;                /* handle to item */
  64.     Rect                    box;                /* item rectangle */
  65.     Str255                tmpl;                /* status message template */
  66.     Str255                msg;                /* status message */
  67.     Str255                heroMsg;            /* hero message */
  68.     Str255                server;            /* login server */
  69.     Str255                alias;            /* login alias */
  70.     EditLoginStatus    status;            /* edit login status */
  71.  
  72.     status = edit_GetStatus(server, alias);
  73.     if (status == editNotLoggedIn) {
  74.         GetIndString(msg, stringsID, notLoggedInMsg);
  75.     } else {
  76.         GetIndString(tmpl, stringsID, statusMsg);
  77.         if (status == editHero) {
  78.             GetIndString(heroMsg, stringsID, heroStatusMsg);
  79.         } else {
  80.             *heroMsg = 0;
  81.         }
  82.         utl_PlugParams(tmpl, msg, server, alias, heroMsg, nil);
  83.     }
  84.     GetDItem(theWindow, itemNo, &itemType, &item, &box);
  85.     TextFont(FontNum);
  86.     TextSize(fontSize);
  87.     TextBox(msg+1, *msg, &box, teJustLeft);
  88.     TextFont(0);
  89.     TextSize(12);
  90. }
  91.  
  92. /*_____________________________________________________________________
  93.  
  94.     DrawNothing - Draw Nothing.
  95.  
  96.     Entry:    theWindow = pointer to dialog window.
  97.                 itemNo = item number of useritem.    
  98. _____________________________________________________________________*/
  99.  
  100. static pascal void DrawNothing (WindowPtr theWindow, short itemNo)
  101.  
  102. {
  103. #pragma unused (theWindow, itemNo)
  104. }
  105.  
  106. /*_____________________________________________________________________
  107.  
  108.     abou_DoCommand - Process About Command.
  109.  
  110.     Entry:    top = pointer to top window record.
  111.                 theMenu = menu number.
  112.                 theItem = menu item number.
  113. _____________________________________________________________________*/
  114.  
  115. #pragma segment command
  116.  
  117. Boolean abou_DoCommand (WindowPtr top, short theMenu, short theItem)
  118.  
  119. {
  120. #pragma unused (top)
  121.  
  122.     DialogPtr            theDialog;            /* pointer to dialog record */
  123.     short                    itemHit;                /* item number hit */
  124.     
  125.     if (theMenu == appleID && theItem == aboutCmd) {
  126.         utl_ModalDialog(aboutID, oop_ModalUpdate, 0, 0, &itemHit, &theDialog,
  127.             DrawStatusMsg, DrawAboutText, utl_FrameItem, DrawNothing);
  128.         DisposDialog(theDialog);
  129.         return true;
  130.     } else {
  131.         return false;
  132.     }
  133. }
  134.  
  135. #pragma segment abou
  136.  
  137. /*_____________________________________________________________________
  138.  
  139.     abou_Init - Initialize.
  140. _____________________________________________________________________*/
  141.  
  142. #pragma segment init
  143.  
  144. void abou_Init (void)
  145.  
  146. {
  147.     oop_RegisterCommandHandler(abou_DoCommand);
  148. }
  149.  
  150. #pragma segment abou
  151.