home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / mac / 1000 / CCE_1044.ZIP / CCE_1044 / XUFSL105.LZH / xufsl.105 / callufsl / callufsl.c next >
C/C++ Source or Header  |  1994-10-01  |  8KB  |  252 lines

  1. #define MAIN
  2.  
  3. #define UFSL_COOKIE     'UFSL'
  4.  
  5. #include <stddef.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9. #include <define.h>
  10. #include <tos.h>
  11. #include <vdi.h>
  12. #include <aes.h>
  13. #include <xufsl.h>
  14. #include <cookie.h>
  15.  
  16. #include "callufsl.h"
  17.  
  18. #define SCREEN 1
  19.  
  20. int Work_in[103],Work_out[57];
  21.  
  22. int main(void);
  23. int open_work(int device);
  24. void close_work(int handle,int device);
  25. void set_state(OBJECT *tree,int obj,int s,int flag);
  26. int selected(OBJECT *tree,int obj);
  27. char *tp_text(OBJECT *tree,int obj);
  28.  
  29. int main(void)
  30. {
  31. char          *ufsl_id,*ufsl_ver;
  32. char                    *u_title,*u_info,*u_bsp;
  33. FW_INFO                width={0,0,0};
  34. int           ufsl_version,version;
  35. int           app,handle,maxfonts;
  36. int           desk_x,desk_y,desk_w,desk_h;
  37.  
  38. int           syssmall=1,sysibm=1;
  39. int           font=1,point=10,attr=0,color=1,skew=0;
  40. int                        sets=4,set_ind=2;
  41. int           but;
  42. int           dummy;
  43. OBJECT        *setflags;
  44. unsigned long flags=0xFFFF;
  45. xUFSL_struct  *ufsl;
  46. XUFSL_LIST         set[4]={
  47.     0x3FF,"Oberstes Fenster",1,0,{0,0,0},0,1,0,
  48.     0x1FF,"Standardschrift",1,0,{0,0,0},0,1,0,
  49.     UFS_GDOS_FONTS|UFS_PROP_FONTS,
  50.         "Dialogschrift klein",273,8,{0,0,0},0,1,0,
  51.     UFS_GDOS_FONTS|UFS_PROP_FONTS,
  52.         "Dialogschrift groß",250,10,{0,0,0},0,1,0,
  53. };
  54.     
  55.  
  56.   if ((ufsl=(xUFSL_struct *)get_cookie(UFSL_COOKIE))==0)
  57.     return FAILURE;
  58.     
  59.   app=appl_init();
  60.   if (app>=0) {
  61.   
  62.     handle=graf_handle(&dummy,&dummy,&dummy,&dummy);
  63.     
  64.     if (handle>0 && rsrc_load("CALLUFSL.RSC")) {
  65.  
  66.       wind_get(0,WF_WORKXYWH,&desk_x,&desk_y,&desk_w,&desk_h);
  67.  
  68.             handle=open_work(SCREEN);
  69.       maxfonts=Work_out[10]+vst_load_fonts(handle,0);
  70.       
  71.       rsrc_gaddr(R_TREE,SETFLAGS,&setflags);
  72.       
  73.       form_center(setflags,&setflags->ob_x,&setflags->ob_y,&dummy,&dummy);
  74.  
  75.       u_title=tp_text(setflags,U_TITLE);
  76.       u_info=tp_text(setflags,U_INFO);
  77.       u_bsp=tp_text(setflags,U_BSP);
  78.       strcpy(u_title,"Extended Fontselektor  \275 RoSoft");
  79.       strcpy(u_info,"Schriftauswahl");
  80.       strcpy(u_bsp,"Textbeispiel");
  81.       ufsl_id=tp_text(setflags,UFSL_ID)+9;
  82.       ufsl_ver=tp_text(setflags,UFSL_VER)+9;
  83.       strncpy(ufsl_id,(char *)&ufsl->id,4);
  84.       
  85.       /* zwar etwas aufwendig, spart jedoch den speicherplatzraubenden
  86.          Aufruf von sprintf! */
  87.       ufsl_version=ufsl->version;
  88.       version=ufsl_version/0x100;
  89.       ufsl_version-=version*0x100;
  90.       itoa(version,ufsl_ver,16);
  91.       strcat(ufsl_ver,".");
  92.             if (ufsl_version<0x10) {
  93.                 strcat(ufsl_ver,"0");
  94.                 itoa(ufsl_version,ufsl_ver+strlen(ufsl_ver),16);
  95.             }
  96.             else
  97.                 itoa(ufsl_version,ufsl_ver+strlen(ufsl_ver),16);
  98.  
  99.       do {
  100.  
  101.         wind_update(BEG_MCTRL);
  102.         itoa(syssmall,tp_text(setflags,U_ID8),10);
  103.         itoa(sysibm,tp_text(setflags,U_ID10),10);
  104.         itoa(font,tp_text(setflags,U_ID),10);
  105.         itoa(point,tp_text(setflags,U_SIZE),10);
  106.         itoa(width.width,tp_text(setflags,U_WIDTH),10);
  107.         itoa(width.track,tp_text(setflags,U_KERN),10);
  108.         set_state(setflags,U_PKERN,SELECTED,width.pair);
  109.         itoa(attr,tp_text(setflags,U_ATTR),10);
  110.         itoa(color,tp_text(setflags,U_COLOR),10);
  111.         set_state(setflags,U_NSKEW,SELECTED,skew<0);
  112.         skew=(skew<0)? -skew : skew;
  113.         itoa(skew,tp_text(setflags,U_SKEW),10);
  114.  
  115.         graf_mouse(ARROW,0);
  116.         objc_draw(setflags,ROOT,MAX_DEPTH,desk_x,desk_y,desk_w,desk_h);
  117.         but=form_do(setflags,ROOT);
  118.         wind_update(END_MCTRL);
  119.  
  120.           form_dial(FMD_FINISH,desk_x,desk_y,desk_w,desk_h,
  121.                                desk_x,desk_y,desk_w,desk_h);
  122.  
  123.         if (but==U_CALL || but==U_SET) {
  124.           
  125.           flags=UFS_WIND_DIALOG*selected(setflags,U_WINDOW)
  126.                |UFS_GDOS_FONTS*selected(setflags,U_GDOS)
  127.                |UFS_PROP_FONTS*selected(setflags,U_PROP)
  128.                |UFS_SIZE_CHANGE*selected(setflags,U_CSIZE)
  129.                |UFS_SIZE_DEFAULT*selected(setflags,U_DSIZE)
  130.                |UFS_WIDTH_CHANGE*selected(setflags,U_CWIDTH)
  131.                |UFS_KERNING_INFO*selected(setflags,U_CKERN)
  132.                |UFS_ATTR_CHANGE*selected(setflags,U_CATTR)
  133.                |UFS_ATTR_INVERS*selected(setflags,U_IATTR)
  134.                |UFS_COLOR_CHANGE*selected(setflags,U_CCOLOR)
  135.                |UFS_SKEW_CHANGE*selected(setflags,U_CSKEW)
  136.                |UFS_ERROR_MSG;
  137.  
  138.           syssmall=atoi(tp_text(setflags,U_ID8));
  139.           sysibm=atoi(tp_text(setflags,U_ID10));
  140.           font=atoi(tp_text(setflags,U_ID));
  141.           point=atoi(tp_text(setflags,U_SIZE));
  142.           width.width=atoi(tp_text(setflags,U_WIDTH));
  143.           width.track=atoi(tp_text(setflags,U_KERN));
  144.           width.pair=selected(setflags,U_PKERN);
  145.           attr=atoi(tp_text(setflags,U_ATTR));
  146.           color=atoi(tp_text(setflags,U_COLOR));
  147.           skew=atoi(tp_text(setflags,U_SKEW));
  148.           if (selected(setflags,U_NSKEW))
  149.             skew=-skew;
  150.  
  151.                     ufsl->examplestr=(u_bsp[0]==EOS)? NULL : u_bsp;
  152.                     ufsl->msgfunc=(MSGFUNC)NULL;
  153.  
  154.           if (ufsl->id==xUFS_ID) {
  155.         
  156.                 if (but==U_SET && ufsl->version>=0x103)
  157.                           ufsl->font_selexinput(handle,
  158.                                                UFS_INDIRECT|flags,
  159.                                      (u_title[0]==EOS)? NULL : u_title,
  160.                                                (string)&set,
  161.                                                syssmall,sysibm,
  162.                                                &sets,&set_ind,&width,&attr,&color,&skew);
  163.               else
  164.                 ufsl->font_selexinput(handle,
  165.                                      flags,
  166.                                      (u_title[0]==EOS)? NULL : u_title,
  167.                                      (u_info[0]==EOS)? NULL : u_info,
  168.                                      syssmall,sysibm,
  169.                                      &font,&point,&width,&attr,&color,&skew);
  170.           }
  171.           else {
  172.           
  173.             ufsl->dialtyp=(flags & UFS_WIND_DIALOG)? UFS_WINDOW : UFS_DIALOG;
  174.             ufsl->fontsel_input(handle,maxfonts,
  175.                                 (flags & UFS_PROP_FONTS)!=0,
  176.                                 (u_info[0]==EOS)? NULL : u_info,
  177.                                 &font,&point);
  178.           
  179.           }
  180.         }
  181.           
  182.         (setflags+but)->ob_state&=~SELECTED;
  183.           
  184.       } while (but==U_CALL || but==U_SET);
  185.  
  186.       rsrc_free();
  187.       close_work(handle,SCREEN);
  188.     }
  189.     appl_exit();
  190.   }
  191.  
  192.   return SUCCESS;
  193. }
  194.  
  195. int open_work(int device)
  196. {
  197. int    i,dummy;
  198. int    handle;
  199.  
  200.     for (i=0;i<103;Work_in[i++]=1);
  201.     Work_in[0]=device;    /* device handle */
  202.     Work_in[10]=2;            /* Raster Koordinaten */
  203.     
  204.     if (device==SCREEN) {
  205.         handle=graf_handle(&dummy,&dummy,&dummy,&dummy);
  206.     v_opnvwk(Work_in,&handle,Work_out);    /* virtuell öffnen */
  207.   }
  208.   else {
  209.         v_opnwk(Work_in,&handle,Work_out);    /* physikalisch öffnen */
  210.   }
  211.     return handle;
  212. }
  213.  
  214. void close_work(int handle,int device)
  215. {
  216.   if (device==SCREEN) {
  217.     v_clsvwk(handle);
  218.     }
  219.     else {
  220.     v_clswk(handle);
  221.   }
  222. }
  223.  
  224. void set_state(OBJECT *tree,int obj,int s,int flag)
  225. {
  226.   if (obj>=0)
  227.     if (flag) (tree+obj)->ob_state |= s;
  228.     else      (tree+obj)->ob_state &= ~s;
  229. }
  230.  
  231. int selected(OBJECT *tree,int obj)
  232. {
  233.   return ((tree+obj)->ob_state & SELECTED)!=0;
  234. }
  235.  
  236. char *tp_text(OBJECT *tree,int obj)
  237. {
  238.   switch ((tree+obj)->ob_type) {
  239.   case G_TEXT:
  240.   case G_BOXTEXT:
  241.   case G_FTEXT:
  242.   case G_FBOXTEXT:
  243.     return (char *)(((tree+obj)->ob_spec.tedinfo)->te_ptext);
  244.   case G_BUTTON:
  245.   case G_STRING:
  246.   case G_TITLE:
  247.     return (char *)((tree+obj)->ob_spec.free_string);
  248.   }
  249.   return NULL;
  250. }
  251.  
  252.