home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / EMBL Search / Sources / info.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-04  |  3.0 KB  |  131 lines  |  [TEXT/KAHL]

  1. /*
  2. *********************************************************************
  3. *    
  4. *    info.c
  5. *    Information alert boxes
  6. *        
  7. *    Rainer Fuchs
  8. *    EMBL Data Library
  9. *    Postfach 10.2209
  10. *    D-6900 Heidelberg, FRG
  11. *    E-mail: fuchs@embl-heidelberg.de
  12. *
  13. *    Copyright Â© 1992 EMBL Data Library
  14. *        
  15. **********************************************************************
  16. *    
  17. */ 
  18.  
  19. #include <stdio.h>
  20.  
  21. #include "EMBL-Search.h"
  22. #include "EMBL-Search.rsrc.h"
  23.  
  24. /*
  25. ******************************* Prototypes ***************************
  26. */
  27.  
  28. #include "info.h"
  29. #include "window.h"
  30. #include "util.h"
  31. #include "pstr.h"
  32.  
  33. static StringPtr GetVersion(void);
  34.  
  35.  
  36. /*
  37. ******************************* Global variables *********************
  38. */
  39.  
  40. extern DBInfo gDBInfo[DB_NUM];
  41. extern short gAppResRef;
  42.  
  43.  
  44. /**************************************
  45. *    Draws About… box
  46. */
  47.  
  48. void ShowAbout()
  49. {
  50.     EventRecord    myEvent;
  51.     DialogPtr    myDialog;
  52.     
  53.     CenterDA('DLOG',ABOUT_DLG,0);
  54.     myDialog=GetNewDialog(ABOUT_DLG,NULL,(WindowPtr)-1);
  55.     SetDlgText(myDialog,ABOUT_VERSION_STR,GetVersion());
  56.     ShowWindow(myDialog);
  57.     DrawDialog(myDialog);
  58.     while(!WaitNextEvent(keyDownMask|autoKeyMask|mDownMask,&myEvent,0L,NULL))
  59.         ;
  60.     DisposDialog(myDialog);
  61. }
  62.  
  63. /**************************************
  64. *    Reads version number from resource file
  65. *    Return value:    Pointer to Pascal string containing the version number
  66. */
  67.  
  68. static StringPtr GetVersion()
  69. {
  70.     short                curResFile;
  71.     VersRecHndl        version;
  72.     static Str255    versNum;
  73.  
  74.     /* store refnum of current resource file */
  75.     curResFile = CurResFile();
  76.     
  77.     UseResFile(gAppResRef);    
  78.     version=(VersRecHndl)Get1Resource('vers',1);
  79.     if(version != NULL) {
  80.         pstrcpy(versNum,(**version).shortVersion);
  81.         ReleaseResource((Handle)version);
  82.     }
  83.     else pstrcpy(versNum,"\p?");
  84.  
  85.     UseResFile(curResFile);    
  86.     return(versNum);
  87. }
  88.  
  89. /**************************************
  90. *    Draws database information dialog
  91. */
  92.  
  93. void ShowDBInfo()
  94. {
  95.     char            str1[256],str2[256];
  96.     Str255        str3,str4;
  97.     DialogPtr    infoDlg;
  98.     short            kind,itemHit;
  99.     Handle        h;
  100.     Rect            r;
  101.  
  102.     CenterDA('DLOG',INFO_DLG,33);
  103.     infoDlg=GetNewDialog(INFO_DLG,NULL,(WindowPtr)-1L);
  104.     
  105.     /* Set user items to draw frame and surround OK button */
  106.     InstallUserItem(infoDlg,INFO_USRITEM1,-1,DrawFrame);
  107.     InstallUserItem(infoDlg,INFO_USRITEM2,OK,DrawOKBoxRect);
  108.  
  109.     /* Set EMBL database release number and date */    
  110.     sprintf(str1,"%s (%s)",gDBInfo[DB_EMBL].DBRelNum,gDBInfo[DB_EMBL].DBRelDate);
  111.     SetDlgText(infoDlg,INFO_EMBL_REL,CtoPstr(str1));
  112.  
  113.     /* Set Swiss-Prot database release number and date */    
  114.     sprintf(str2,"%s (%s)",gDBInfo[DB_SWISS].DBRelNum,gDBInfo[DB_SWISS].DBRelDate);
  115.     SetDlgText(infoDlg,INFO_SWISS_REL,CtoPstr(str2));
  116.  
  117.     /* Set # of entries in EMBL to # of records in entry name index */
  118.     NumToString(gDBInfo[DB_EMBL].ename_nrec,str3);
  119.     SetDlgText(infoDlg,INFO_EMBL_ENTRIES,str3);
  120.  
  121.     /* Set # of entries in Swiss-Prot to # of records in entry name index */
  122.     NumToString(gDBInfo[DB_SWISS].ename_nrec,str4);
  123.     SetDlgText(infoDlg,INFO_SWISS_ENTRIES,str4);
  124.  
  125.     ShowWindow(infoDlg);
  126.     DrawDialog(infoDlg);
  127.     do {
  128.         ModalDialog(NULL,&itemHit);
  129.     } while (itemHit != OK);
  130.     DisposDialog(infoDlg);
  131. }