home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / varie / charmap / source / cmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-04  |  16.1 KB  |  499 lines

  1. /******************************************************************
  2. ** charmap.c : Affiche la table ascii d'une police de caractère  **
  3. **             Écrit (en partie) par T.Pierron                   **
  4. **             11-Déc-1999                                       **
  5. **---------------------------------------------------------------**
  6. ** Special Requirements: WorkBench 2.0, version 36 or above      **
  7. ******************************************************************/
  8.  
  9. #include <Intuition/Intuition.H>
  10. #include <Intuition/IntuitionBase.H>
  11. #include <Graphics/RastPort.H>
  12. #include <Graphics/Text.H>
  13. #include <Libraries/Gadtools.H>
  14. #include <Intuition/Screens.H>
  15.  
  16. #include "cmap.h"
  17. #define  CATCOMP_NUMBERS        /* We will need the string id */
  18. #define  CATCOMP_STRINGS        /* and the english string corresponding to this id */
  19. #include "cmap_strings.h"
  20.  
  21. /* Shared libraries we'll need to open */
  22. struct IntuitionBase *IntuitionBase = NULL;
  23. struct GfxBase *GfxBase       = NULL;
  24. struct Library *GadToolsBase  = NULL;
  25. struct Library *AslBase       = NULL;
  26. struct Library *DiskfontBase  = NULL;
  27. struct Library *CxBase            = NULL;
  28. struct Library *IconBase        = NULL;
  29. struct Library *KeymapBase        = NULL;
  30. struct Library *LocaleBase    = NULL;
  31. void           *clipdev            = NULL;
  32.  
  33. /* Graphics area: */
  34. struct RastPort *RP,RPT;
  35. struct TextFont *font,*newfont=0;
  36.  
  37. struct Menu   *menu   = NULL;                /* Menu attached to the window */
  38. struct Screen *screen = NULL;                /* Screen where window will be opened */
  39. struct Window *window = NULL;                /* Main window ptr */
  40. struct Gadget *glist  = NULL;             /* Gadget list pointer */
  41. struct Gadget *gad;                            /* our running Gadget pointer */
  42. struct Gadget *copy_gad, *paste_gad;    /* Copy and paste gadget (for menu action) */
  43. void   *vi = NULL;                            /* VisualInfo pointer */
  44.  
  45. WORD  ZoomData[4];                            /* Position of iconified window */
  46. WORD  xdeb,ydeb,xfin,yfin,X,Y;            /* Position of ASCII table */
  47. UBYTE CharWid[256],Char[]=" ";            /* Data of ASCII table */
  48. UBYTE Font_height;                            /* Font information */
  49. UBYTE GadDisable=0;                            /* If ressource unavailable */
  50. WORD  W,Wid,len;                                /* Width of gadget */
  51.  
  52. /* For the "version" command: */
  53. const UBYTE VERSION[]= "$VER:CharMap v" CHARMAP_VERSION " " CHARMAP_DATE "\n";
  54.  
  55. /* Tag list for openning the main window: */
  56. ULONG WinTags[] = {
  57.     WA_Zoom,(ULONG)ZoomData,
  58.     WA_NewLookMenus,TRUE,
  59.     TAG_DONE
  60. };
  61.  
  62. /* For our string gadget: */
  63. ULONG StrTags[] = {
  64.     GTST_MaxChars,50,
  65.     TAG_DONE
  66. };
  67.  
  68. /* Set the color of the menu to Newlook (only 3.0+): */
  69. ULONG MenuTags[] = {
  70.     GTMN_FrontPen, 1,
  71.     TAG_DONE
  72. };
  73.  
  74. ULONG BoxTags[] = {
  75.     GT_VisualInfo,0,
  76.     TAG_DONE,FALSE,
  77.     TAG_DONE
  78. };
  79.  
  80. /* Our gadtools gadgets text: */
  81. UBYTE *GadTxt[7+NUM_CHARSET]={
  82.     "<=",
  83.     MSG_NEWFONT_STR,
  84.     NM_BARLABEL,
  85.     MSG_COPY_STR,
  86.     MSG_PASTE_STR,
  87.     MSG_STRGAD_STR
  88. };
  89.  
  90. ULONG CycleTags[]= {
  91.     GTCY_Labels, (ULONG) &GadTxt[6],
  92.     GTCY_Active, 1,
  93.     TAG_DONE
  94. };
  95.  
  96.  
  97. /* here we declare the information for our new window - notice that GadTools
  98.  * provides some constants which describe which IDCMP events the Window will
  99.  * need to handle the GadTools Gadgets properly. Just OR them into your
  100.  * normal IDCMPFlags field.
  101.  */
  102.  
  103. ULONG sigwin=0;
  104. struct NewWindow new_window = {
  105.     50, 20, 510, 150,
  106.     -1, -1,                        /* DetailPen, BlockPen */
  107.     CLOSEWINDOW | REFRESHWINDOW | MOUSEBUTTONS | MOUSEMOVE | RAWKEY | MENUPICK | MENUVERIFY | GADGETUP,
  108.     ACTIVATE | WINDOWDRAG | WINDOWDEPTH | WINDOWCLOSE | SMART_REFRESH | REPORTMOUSE,
  109.     NULL,                            /* FirstGadget */
  110.     NULL,                            /* CheckMark */
  111.     NULL,                            /* Title */
  112.     NULL,                            /* Screen */
  113.     NULL,                            /* BitMap */
  114.     0, 0, 0, 0,                    /* min/max sizes */
  115.     CUSTOMSCREEN
  116. };
  117.  
  118. /* Error messages: */
  119. UBYTE *Errors[]= {
  120.     MSG_BADOS_STR,
  121.     MSG_SCREENLOCK_STR,
  122.     MSG_ERRLAYOUT_STR,
  123.     MSG_FONTREALLYBIG_STR,
  124.     MSG_ERRGADGET_STR,
  125.     MSG_ERRNOMEM_STR,
  126.     MSG_NEXTSCR_STR            /* When commo is not present */
  127. };
  128.  
  129. struct EasyStruct Request=
  130. { sizeof(struct EasyStruct),0,
  131.   MSG_ABOUT_STR,
  132.   MSG_ABOUTMSG_STR,
  133.   MSG_CONTINUE_STR
  134. };
  135.  
  136. /**********************************************************
  137. *****                    MENU DATA MANAGMENT:                        *****
  138. **********************************************************/
  139.  
  140. /* NewMenu menu declaration */
  141. struct NewMenu newmenu[] =
  142. {
  143.     {NM_TITLE, MSG_MENUTITLE_STR,0 , 0, 0, 0},
  144.     {  NM_ITEM, MSG_FONTTYPE_STR, 0, 0, 0, 0},
  145.     {   NM_SUB, MSG_MENUFONTSCREEN_STR,"S", CHECKIT|CHECKED, ~1, (APTR) 11},
  146.     {   NM_SUB, MSG_MENUTEXTFONT_STR,  "T", CHECKIT, ~2, (APTR)12},
  147.     {   NM_SUB, MSG_MENUCUSTOMFONT_STR,"F", CHECKIT, ~4, (APTR)13},
  148.     {  NM_ITEM, NM_BARLABEL,  0, 0, 0, 0},
  149.     {  NM_ITEM, MSG_MENUCHARSET_STR,   0, 0, 0, 0},
  150.     {   NM_SUB,   MSG_MENUASCII8_STR,    "1", CHECKIT, ~1, (APTR)141},
  151.     {   NM_SUB,   MSG_MENUISOLATIN1_STR, "2", CHECKIT, ~2, (APTR)142},
  152.     {   NM_SUB,   MSG_MENUSTDAMIGA_STR,  "3", CHECKIT, ~4, (APTR)143},
  153.     {  NM_ITEM, MSG_MENUABOUT_STR,       "?", 0, 0, (APTR)15},
  154.     {  NM_ITEM, NM_BARLABEL,  0, 0,  0, 0},
  155.     {  NM_ITEM, MSG_MENUICONOFY_STR,     "I", 0, 0, (APTR)16},
  156.     {  NM_ITEM, MSG_MENUHIDE_STR,        "H", 0, 0, (APTR)17},
  157.     {  NM_ITEM, MSG_MENUQUIT_STR,        "Q", 0, 0, (APTR)18},
  158.  
  159.     {NM_TITLE, MSG_EDITMENU_STR ,0, 0, 0, 0},
  160.     {  NM_ITEM, MSG_CUT_STR,             "X", 0, 0, (APTR)21},
  161.     {  NM_ITEM, NM_BARLABEL,             "C", 0, 0, (APTR)22},
  162.     {  NM_ITEM, NM_BARLABEL,             "V", 0, 0, (APTR)23},
  163.     {  NM_ITEM, NM_BARLABEL,  0, 0,  0, 0},
  164.     {  NM_ITEM, MSG_MENUCLEARTXT_STR,  "Del", NM_COMMANDSTRING, 0, (APTR)24},
  165. /*    {  NM_ITEM, NM_BARLABEL,  0, 0,  0, 0},
  166.     {  NM_ITEM, MSG_SAVESETTINGS,          0, 0,  0, (APTR)26},
  167. */    {NM_END, 0, 0, 0, 0, 0},
  168. },*checked=&newmenu[NM_FONTTYPE],
  169.   *checkset;
  170.  
  171. /* Different width of box for each charset: */
  172. UBYTE MaxWid,NumChars,CharsetNum=0;
  173.  
  174. /* Colors pens: */
  175. UWORD fillpen=3,txtpen=1,poppen=2,filltxt=2;
  176.  
  177. /* Position of normal and minimized window: */
  178. WORD Offset[]={0x7FFF,0x7FFF,0x7FFF,0x7FFF};
  179.  
  180. /* Function prototypes */
  181. BYTE setup();                                        /* Open window, ressources, font... */
  182. void cleanup(UBYTE *,WORD);                    /* Quit properly */
  183. void create_gadgets(void);                        /* Create the gadget using gadtools lib */
  184. void handle_input(void);                        /* Handle intuition events */
  185. void Init_helpwin();                                /* Alloc memory for help window */
  186. void Open_helpwin(UBYTE, WORD, WORD);        /* Show the help window */
  187. void Free_helpwin();                                /* Free all allocated memory */
  188. void Close_helpwin();                            /* Cleanup the display */
  189.  
  190. /**** Definition of the main loop: ****/
  191. int main(int argc, char *argv[])
  192. {
  193.     extern BOOL PopWin;                                    /* True if the window is poped up at start */
  194.  
  195.     /* Open ze libraries */
  196.     if( (CxBase   = (void *) OpenLibrary("commodities.library", 37L)) &&
  197.          (IconBase = (void *) OpenLibrary("icon.library",        36L)) )
  198.         /* If the icon and commodities.library are present, and the    **
  199.         ** programm failed to init as a commodity, it's probably        **
  200.         ** because it is already running, and user want to quit:        */
  201.     {    if( Init_commodity(argc,argv)==FALSE )
  202.             cleanup(0,0);
  203.     } else {
  204.         /* If commo. is not present, change menu Hide by Next screen: */
  205.         newmenu[13].nm_Label = ErrMsg(MSG_NEXTSCR);
  206.         newmenu[13].nm_CommKey = "J";
  207.         newmenu[13].nm_UserData = (APTR)25;
  208.     }
  209.  
  210.     /* These libraries are located in ROM. If it failed to open, it's   **
  211.     ** because we are attempting to run this programme on an old system */
  212.     if( !(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", MIN_VERSION)) ||
  213.         !(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",MIN_VERSION)) ||
  214.         !(GadToolsBase = (struct Library *)OpenLibrary("gadtools.library",MIN_VERSION)) ||
  215.         !(KeymapBase = (struct Library *)OpenLibrary("keymap.library",37)) )
  216.         cleanup(ErrMsg(MSG_BADOS),30);
  217.  
  218.     /* If no locale, use english as default: */
  219.     if(LocaleBase = (struct Library *)OpenLibrary("locale.library", 38))
  220.         Translate_srings();
  221.  
  222.     /* Same as gadget or menu text: */
  223.     newmenu[17].nm_Label=GadTxt[3];
  224.     newmenu[18].nm_Label=GadTxt[4];
  225.     GadTxt[2]=newmenu[6].nm_Label;
  226.      for(checkset=&newmenu[NM_CHARSET], X=6; X<6+NUM_CHARSET; X++,checkset++)
  227.         GadTxt[ X ]=checkset->nm_Label;
  228.  
  229.     /* No ASL or diskfont library, no font requester */
  230.     if( !(AslBase = (struct Library *)OpenLibrary("asl.library",MIN_VERSION)) ||
  231.         !(DiskfontBase  = (struct Library *)OpenLibrary("diskfont.library",0)) ) {
  232.         newmenu[NM_FONTTYPE+2].nm_Flags |= NM_ITEMDISABLED;
  233.         GadDisable |= 2;
  234.     }
  235.  
  236.     /* For temporary font measurement: */
  237.     InitRastPort( &RPT );
  238.  
  239.     /* Get access to the frontmost screen */
  240.     screen = (struct Screen *) IntuitionBase->ActiveScreen;
  241.     font = screen->RastPort.Font;
  242.  
  243.     /* Initial charset displayed: */
  244.     if(CharsetNum<1 || CharsetNum>NUM_CHARSET) Init_charset(font);
  245.     checkset=&newmenu[CharsetNum+NM_CHARSET-1];
  246.     checkset->nm_Flags |= CHECKED;
  247.  
  248.     if(PopWin)
  249.         /* If setup failed at start (font too big): */
  250.         if(setup()) Handle_menu(13L);
  251.  
  252.     handle_input();
  253. }
  254.  
  255. /**** Setup the window, return 1 if init failed: ****/
  256. BYTE setup()
  257. {
  258.     struct DrawInfo *di;
  259.  
  260.     /* get the screen's visual information data */
  261.     if( !(vi = (void *) GetVisualInfoA( screen,NULL )) )
  262.         cleanup(ErrMsg(MSG_SCREENLOCK),30);
  263.  
  264.     BoxTags[1]=(ULONG)vi;
  265.  
  266.     /* Adjust the pen number to what the screen uses: */
  267.     if( di = (void *)GetScreenDrawInfo(screen))
  268.     {
  269.         /* Get a copy of the correct pens for the screen: */
  270.         fillpen = di->dri_Pens[FILLPEN];
  271.         txtpen  = di->dri_Pens[TEXTPEN];
  272.         filltxt = poppen = di->dri_Pens[FILLTEXTPEN];
  273.         if(poppen==txtpen) poppen=fillpen;
  274.  
  275.         /* This one is only available on system V39+: */
  276.         if(di->dri_Version>=2) MenuTags[1] = di->dri_Pens[BARDETAILPEN];
  277.         FreeScreenDrawInfo(screen,di);
  278.     }
  279.  
  280.     /* Build the menu-strip and compute menu items size: */
  281.     if( !(menu = (void *) CreateMenusA(newmenu, MenuTags)) ||
  282.         !LayoutMenusA(menu, vi, NULL) )
  283.        cleanup(ErrMsg(MSG_ERRLAYOUT),30);
  284.  
  285.     SetFont(&RPT,font);
  286.     /* Read the size of the 256 characters of the current font, **
  287.     ** and compute the maximal width of the box chars:          */
  288.     NumChars = CharsetNum==1 ? 32 : CharsetNum == 2 ? 28 : 24;
  289.     {
  290.         register WORD I;
  291.         register UBYTE *W;
  292.         for(I=0,W=CharWid,MaxWid=0; I<256; I++,W++) {
  293.             *Char = I;
  294.             *W = TextLength(&RPT,Char,1);
  295.  
  296.             /* Compute the width of each box: */
  297.             switch( CharsetNum )
  298.             {
  299.                 case 3: if(I>=127 && I<160) break;
  300.                 case 2: if(I<32) break;
  301.                 case 1: if(MaxWid < *W+6) MaxWid=*W+6;
  302.             }
  303.         }
  304.     }
  305.  
  306.     Font_height = font->tf_YSize+4;
  307.     SetFont(&RPT,screen->RastPort.Font);
  308.     W   = TextLength(&RPT,GadTxt[2],strlen(GadTxt[2]));            /* "Charset" string */
  309.     len = TextLength(&RPT,GadTxt[8],strlen(GadTxt[8]))+30;        /* Cycle gadget */
  310.     xdeb= TextLength(&RPT,GadTxt[1],strlen(GadTxt[1]))+10;        /* Choose font gadget */
  311.  
  312.     for(;;) {
  313.         /* Computes the width of our window: */
  314.         new_window.Width = xfin = MaxWid*NumChars+20;
  315.  
  316.         /* Computes the widths of the bottom row of gadgets: */
  317.         Wid = (xfin - 50 - W) / 3;
  318.         if(Wid<len)    Wid = (xfin - 50 - W - len) / 2;
  319.         else            len = Wid;
  320.  
  321.         /* Is the width of the window enough to place gadgets? */
  322.         if(Wid < xdeb ) MaxWid += 1+(xdeb-Wid)/NumChars;
  323.         else break;
  324.     }
  325.  
  326.     /* Does the width of the window fit in the screen ? */
  327.     if(xfin > screen->Width)
  328.     {
  329.         /* No! force the window width: */
  330.         MaxWid = (screen->Width-20) / NumChars;
  331.         new_window.Width = xfin = MaxWid*NumChars+20;
  332.     }
  333.  
  334.     new_window.TopEdge  = Adjust_pos(Offset[1],screen->Height,
  335.     new_window.Height   = Font_height*8+3*screen->Font->ta_YSize+35 );
  336.     new_window.Screen   = screen;
  337.     new_window.LeftEdge = Adjust_pos(Offset[0],screen->Width,xfin);
  338.  
  339.     /* Title of the window is the name of our font: */
  340.     new_window.Title    = font->tf_Message.mn_Node.ln_Name;
  341.  
  342.     /* Init the position and the size of the minimized window: */
  343.     ZoomData[0] = Adjust_pos(Offset[2],screen->Width,
  344.     ZoomData[2] = TextLength(&screen->RastPort,new_window.Title,strlen(new_window.Title))+100);
  345.     ZoomData[1] = Adjust_pos(Offset[3],screen->Height,
  346.     ZoomData[3] = screen->BarHeight+1);
  347.  
  348.     /* If this call failed, the font is VERY too much big! */
  349.     if( !(window = (void *) OpenWindowTagList(&new_window,WinTags)) )
  350.         /* If ASL is avaible, show a requester to change the font: */
  351.         if( avert(ErrMsg(MSG_FONTREALLYBIG)) && AslBase )
  352.             return TRUE;
  353.         else cleanup(0,0);
  354.  
  355.     /* Signal bit, to process events from the window: */
  356.     sigwin = 1 << window->UserPort->mp_SigBit;
  357.     SetMenuStrip(window, menu);    /* Attach the menu to the window */
  358.     create_gadgets();                    /* Creates all gadgets */
  359.     Init_helpwin();                    /* Init the help win, using width height of the current font: */
  360.     return FALSE;
  361. }
  362.  
  363. /**** Desallocate all ressources: ****/
  364. void cleanup(UBYTE *msg,WORD err)
  365. {
  366.     extern APTR FR;
  367.     extern void *catalog;
  368.  
  369.     if (msg)            puts(msg);
  370.     if (window)    {
  371.         ClearMenuStrip(window);
  372.         CloseWindow(window);
  373.         window=NULL;
  374.     }
  375.  
  376.     /* These two functions can take a NULL, but let's stay consistent */
  377.     if (glist) FreeGadgets(glist);    glist=0;
  378.     if (vi) FreeVisualInfo(vi);        vi=0;
  379.     if (menu) FreeMenus(menu);            menu=0;
  380.     Free_helpwin();
  381.  
  382.     if (err<0) return;
  383.     Free_commodity();
  384.     if (FR)                    FreeAslRequest(FR);
  385.     if (newfont)            CloseFont(newfont);
  386.     if (catalog)            CloseCatalog(catalog);
  387.     if (clipdev)            CBClose(clipdev);
  388.     if (CxBase)                CloseLibrary(CxBase);
  389.     if (AslBase)            CloseLibrary(AslBase);
  390.     if (IconBase)            CloseLibrary(IconBase);
  391.     if (KeymapBase)        CloseLibrary(KeymapBase);
  392.     if (LocaleBase)        CloseLibrary(LocaleBase);
  393.     if (DiskfontBase)        CloseLibrary(DiskfontBase);
  394.     if (GadToolsBase)        CloseLibrary(GadToolsBase);
  395.     if (IntuitionBase)    CloseLibrary(IntuitionBase);
  396.     if (GfxBase)            CloseLibrary(GfxBase);
  397.     exit(err);
  398. }
  399.  
  400. /**** Draw the table of characters: ****/
  401. void Draw_ASCIIChart()
  402. {
  403.     register WORD i,x,y;
  404.  
  405.     /* Initial bevel box, which will be copied 256 times: */
  406.     DrawBevelBoxA(RP,xdeb,ydeb,MaxWid,Font_height,BoxTags);
  407.  
  408.     /* Exponential copy (very fast :-) */
  409.     for(x=MaxWid,i=xdeb+x,y=window->Width-10; i<xfin; ) {
  410.         ClipBlit(RP,xdeb,ydeb,RP,i,ydeb,x,Font_height,0xC0);
  411.         i+=x; x<<=1; if(i+x>y) x=y-i;
  412.     }
  413.  
  414.     for(x=Font_height,i=ydeb+x; i<yfin; i+=x,x<<=1)
  415.         ClipBlit(RP,xdeb,ydeb,RP,xdeb,i,y,x,0xC0);
  416.  
  417.     /* Character in each box: */
  418.     SetAPen(RP,txtpen);
  419.     for(i=CharsetNum==1?0:32,x=xdeb; i<256; i++,y+=Font_height)
  420.     {
  421.         if(CharsetNum==3 && i==127) { i=160; goto NL; }
  422.         if( (i&7)==0 ) { NL: y=ydeb; x+=MaxWid; }
  423.         *Char = i;
  424.         Move(RP,x-(MaxWid+CharWid[i]>>1),y+font->tf_Baseline+2);
  425.         Text(RP,Char,1);
  426.     }
  427. }
  428.  
  429. /**** Create the gadgets associated with the window: ****/
  430. void create_gadgets()
  431. {
  432. #    define tmpgad        ((struct Gadget *)RP)
  433.     struct NewGadget ng={65,5,0,14,0,0,5,PLACETEXT_LEFT | NG_HIGHLABEL,0,0};
  434.     extern UBYTE  *StrBuf;
  435.     UWORD  top,I;
  436.  
  437.     /* «Constant» variables: */
  438.     top = window->BorderTop + 1;
  439.     gad = (void *) CreateContext(&glist);
  440.     RP  = &screen->RastPort;
  441.  
  442.     ng.ng_TextAttr = screen->Font;
  443.     ng.ng_VisualInfo = vi;
  444.  
  445.     /*    the NewGadget stucture is not modified by any Gadget creation call,
  446.         so you'll only need to change information that actually needs to be
  447.         changed */
  448.     ng.ng_GadgetText = GadTxt[5];
  449.     if( W < (ng.ng_LeftEdge = TextLength(RP,GadTxt[5],strlen(GadTxt[5]))+20) )
  450.         ng.ng_LeftEdge = W+20;
  451.      ng.ng_Width = window->Width - 20 - Wid - ng.ng_LeftEdge -
  452.     (ng.ng_Height = screen->Font->ta_YSize+6);
  453.     ng.ng_TopEdge += top;
  454.  
  455.     tmpgad = gad = (void *) CreateGadgetA(STRING_KIND, gad, &ng, StrTags);
  456.  
  457.     *(StrBuf = sti(gad)->Buffer)=0;
  458.     /* Name of the charset displayed in the cycle gad: */
  459.     CycleTags[3]=CharsetNum-1;
  460.  
  461.     /* Create the 5 gadgets shorcut: */
  462.     ng.ng_LeftEdge -= 10;
  463.     for(I=0; I<5; I++)
  464.     {
  465.         ng.ng_LeftEdge+=ng.ng_Width+10;
  466.         if(I==2) { ng.ng_Width = len; ng.ng_Flags = PLACETEXT_LEFT | NG_HIGHLABEL;    ng.ng_Height -= 2;
  467.                    ng.ng_LeftEdge = 20+W; top = (ng.ng_TopEdge += ng.ng_Height+6); }
  468.         else     { ng.ng_Width = I==0?ng.ng_Height:Wid; ng.ng_Flags = PLACETEXT_IN; }
  469.         ng.ng_GadgetID   = I;
  470.         ng.ng_GadgetText = GadTxt[I];
  471.         tmpgad = (void *) CreateGadgetA(I==2 ? CYCLE_KIND:BUTTON_KIND, tmpgad, &ng, I==2 ? CycleTags:NULL);
  472.  
  473.         if(I==3) copy_gad=tmpgad; if(I==4) paste_gad=tmpgad;
  474.  
  475.         /* If a ressource isn't available, disable the corresponding gadget: */
  476.         if(GadDisable & (1<<I)) tmpgad->Flags |= GADGDISABLED;
  477.     }
  478.  
  479.     /*    Now we're ready to add the Gadget list. Quit if the final Gadget
  480.         pointer is NULL - this means that one of the Gadget allocations failed.
  481.         If it exists, add it to the window and refresh, then add the new
  482.         GT_RefreshWindow() call. */
  483.  
  484.     if (!tmpgad)
  485.         cleanup(ErrMsg(MSG_ERRGADGET),30);
  486.  
  487.     AddGList(window, glist, (UWORD)-1, (UWORD)-1, NULL);
  488.     RefreshGList(glist, window, NULL, (UWORD)-1);
  489.     GT_RefreshWindow(window, NULL);
  490.     RP=window->RPort;
  491.     SetFont(RP,font);
  492.     SetDrMd(RP,JAM1);
  493.  
  494.     /* Draw the ASCII table: */
  495.     xdeb = 10;            ydeb = top+ng.ng_Height+5;
  496.     xfin -= 10;            yfin  = ydeb+Font_height*8;
  497.     Draw_ASCIIChart();
  498. }
  499.