home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / diskutil / gemar / ufsl / fonttest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-31  |  4.7 KB  |  175 lines

  1. #include <portab.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <aes.h>
  6. #include <vdi.h>
  7. #include <tos.h>
  8.  
  9. #define SCREEN 1
  10. #define MONO   1
  11.  
  12. #define DIALOG 0
  13. #define WINDOW 1
  14.  
  15. int cdecl fontsel_input(int handle, int ncount, int ftype, char *text, int *id, int *size);
  16.  
  17. int work_in[103],work_out[57];
  18. int aeshandle,vdihandle;
  19. char alertstr[256];
  20.  
  21. typedef struct
  22. {
  23.    unsigned long  id;      /* UFSL ID (UFSL)       */
  24.    unsigned int   version; /* version (BCD-Format) */
  25.    int dialtyp;            /* 0=Dialog, 1=Fenster  */
  26.    int cdecl (*fontsel_init)(void);
  27.    int cdecl (*fontsel_input)(int vdihandle, /* klar */
  28.                               int n_fonts,   /* Gesamtzahl der Fonts */
  29.                               int ftype,     /* 1=nur monospaced, 0=egal */
  30.                               char *text,    /* Benutzerdefinierter Text */
  31.                               int *fretid,   /* eingestellte FontId */
  32.                               int *fretsize  /* eingestellte Fontgröße */
  33.                               );
  34.    OBJECT *helpbutton;                       /* Typ: BOXTEXT */
  35.    int cdecl (*helpfunc)(void);              /* Benutzerdefinierte Helpfkt. */
  36.    char *examplestr;                         /* Beispielstring */
  37. } UFSL;
  38.  
  39. /* ----- Cookie Jar -------------------------------------------------------- */
  40.  
  41. typedef struct
  42. {
  43.    long  id,
  44.       *ptr;
  45. } COOKJAR;
  46.  
  47. /* ------------------------------------------------------------------------- */
  48. /* ----- get_cookie -------------------------------------------------------- */
  49. /* ------------------------------------------------------------------------- */
  50.  
  51. static long *get_cookie(long cookie)
  52. {
  53.    long  sav;
  54.    COOKJAR  *cookiejar;
  55.    int   i = 0;
  56.  
  57.    sav = Super((void *)1L);
  58.    if(sav == 0L)
  59.       sav = Super(0L);
  60.    cookiejar = *((COOKJAR **)0x05a0l);
  61.    if(sav != -1L)
  62.       Super((void *)sav);
  63.    if(cookiejar)
  64.    {
  65.       while(cookiejar[i].id)
  66.       {
  67.          if(cookiejar[i].id == cookie)
  68.             return(cookiejar[i].ptr);
  69.          i++;
  70.       }
  71.    }
  72.    return(0l);
  73. }
  74.  
  75. int open_work (int device)
  76. {
  77.    register int i;
  78.    int handle;
  79.  
  80.    for (i = 0; i < 103; i++) work_in [i] = 1;
  81.    work_in [0]  = device;                         /* device handle */
  82.    work_in [10] = 2;                         /* Raster Koordinaten */
  83.  
  84.    if (device == SCREEN)
  85.    {
  86.      handle=aeshandle;
  87.      v_opnvwk (work_in, &handle, work_out);     /* virtuell öffnen */
  88.    }
  89.    else                                        /* nicht Bildschirm */
  90.    {
  91.      v_opnwk (work_in, &handle, work_out);  /* physikalisch öffnen */
  92.    }
  93.    return (handle);
  94. }
  95.  
  96. void close_work (int handle, int device)
  97. {
  98.   switch (device)
  99.   {
  100.     case SCREEN:
  101.        v_clsvwk (handle);
  102.        break;
  103.     default:
  104.        v_clswk (handle);
  105.        break;
  106.   }
  107. }
  108.  
  109. int cdecl helpfunc(OBJECT *tree)
  110. {
  111.    form_alert(1,"[0][|Hilfstext][  OK  ]");
  112. }
  113.  
  114. main()
  115. {
  116.    int ret,id,size,n_fonts,done=FALSE;
  117.    UFSL *ufsl;
  118.  
  119.    appl_init();
  120.    graf_mouse(ARROW,NULL);
  121.    aeshandle=graf_handle(&ret,&ret,&ret,&ret);
  122.    vdihandle=open_work(SCREEN);
  123.  
  124.    vq_extnd(vdihandle,0,work_out);
  125.  
  126.    if(vq_gdos())
  127.       n_fonts=vst_load_fonts(vdihandle,0)+work_out[10];
  128.    else
  129.       n_fonts=work_out[10]; /* Nur 6x6 system font */
  130.    ufsl=(UFSL *)get_cookie('UFSL');
  131.    if(ufsl)
  132.    {
  133.       ufsl->fontsel_init();
  134.       ufsl->dialtyp=DIALOG;
  135.       ufsl->helpbutton->ob_width=7*(strlen("HILFE")+3);
  136.       ufsl->helpbutton->ob_flags=SELECTABLE|EXIT;
  137.       ufsl->helpbutton->ob_state=OUTLINED|SHADOWED;
  138.       ufsl->helpbutton->ob_spec.tedinfo->te_font=SMALL;
  139.       strcpy(ufsl->helpbutton->ob_spec.tedinfo->te_ptext,"HILFE");
  140.       ufsl->helpfunc=helpfunc;
  141.       do
  142.       {
  143.          switch(ufsl->fontsel_input(vdihandle,n_fonts,0,"Bitte Font auswählen",&id,&size))
  144.          {
  145.             case TRUE:
  146.                sprintf(alertstr,"[1][|FontId: %d, Fontgröße: %dpt.][  OK  ]",id,size);
  147.                form_alert(1,alertstr);
  148.                vst_font(vdihandle,id);
  149.                vst_point(vdihandle,size,&ret,&ret,&ret,&ret);
  150.                break;
  151.             case FALSE:
  152.                form_alert(1,"[1][|Abbruch gewählt. ][  OK  ]");
  153.                done=TRUE;
  154.                break;
  155.             case -1:
  156.                form_alert(1,"[3][|Out of Memory! ][  OK  ]");
  157.                done=TRUE;
  158.                break;
  159.             case -2:
  160.                form_alert(1,"[3][|Mehrfachaufruf nicht möglich! ][  OK  ]");
  161.                done=TRUE;
  162.                break;
  163.          }
  164.       }
  165.       while(!done);
  166.    }
  167.    else
  168.       form_alert(1,"[1][|Kein gültiger UFSL-Cookie! ][  OK  ]");
  169.    if(vq_gdos())
  170.       vst_unload_fonts(vdihandle,0);
  171.    close_work(vdihandle,SCREEN);
  172.    appl_exit();
  173. }
  174.  
  175.