Exemplo n.º 1
0
void forceCloseWindow(FrameworkWindow *window) {
  forceCloseChildren(window);

  if(window->menu) {
    ClearMenuStrip(window->intuitionWindow);
    FreeMenus(window->menu);
  }

  CloseWindow(window->intuitionWindow);

  if(window->kind->freeGadgets) {
    (*window->kind->freeGadgets)(window->gadgets);
  }

  if(window->kind->closeWindow) {
    (*window->kind->closeWindow)(window);
  }

  if(window->parent) {
    removeChildWindow(window->parent, window);
  }

  if(window->next) {
    window->next->prev = window->prev;
  }

  if(window->prev) {
    window->prev->next = window->next;
  }

  free(window);
}
Exemplo n.º 2
0
__autoexit void amiga_exit (void)
{
  int i;

  for (i = 0; i < HISTORY_LINES; i++)
  {
    if (*(History + i))
      FreeVec (*(History + i));
    *(History + i) = 0;
  }

  if (GameReq)
    FreeAslRequest (GameReq);
  if (SaveReq)
    FreeAslRequest (SaveReq);
  if (ScriptReq)
    FreeAslRequest (ScriptReq);
  if (Menus)
    FreeMenus (Menus);
  if (Visual)
    FreeVisualInfo (Visual);
  if (ThisProcess)
    ThisProcess->pr_WindowPtr = OldWindowPtr;
  if (Window)
    CloseWindow (Window);
  if (Screen)
    CloseScreen (Screen);
  if (Font)
    CloseFont (Font);
  if (DefaultPubScreen)
    UnlockPubScreen (0, DefaultPubScreen);
  if (Icon)
    FreeDiskObject (Icon);
}
Exemplo n.º 3
0
void CBDCApp::FreeMenus(menu_entry_t** pmenu_entry)
{
	if( (*pmenu_entry)->next_menu != NULL )
	{
		FreeMenus(&(*pmenu_entry)->next_menu);
	}
	if( (*pmenu_entry)->text )
		free((*pmenu_entry)->text);
	free(*pmenu_entry);
}
Exemplo n.º 4
0
// Free a menu
void display_free_menu(struct Window *window)
{
	struct Menu *menu;

	// Free existing menu
	if (window && (menu=window->MenuStrip))
	{
		ClearMenuStrip(window);
		FreeMenus(menu);
	}
}
Exemplo n.º 5
0
static void vsid_menu_destroy(void)
{
    if (vsid_menu) {
        ClearMenuStrip(vsid_window);
        FreeMenus(vsid_menu);
        vsid_menu = NULL;
    }

    if (VisualInfo) {
        FreeVisualInfo(VisualInfo);
        VisualInfo = NULL;
    }
}
Exemplo n.º 6
0
void AMI_ILBM_destroyViewerDisplay(void)
{
    deleteCycleTask(viewerDisplay.task);
    
    if(viewerDisplay.menu != NULL)
    {
	ClearMenuStrip(viewerDisplay.window); /* Remove the menu strip from the window */
	FreeMenus(viewerDisplay.menu);
    }
    
    if(viewerDisplay.window != NULL)
	CloseWindow(viewerDisplay.window);

    AMI_ILBM_destroyImage(&viewerDisplay.image);
}
Exemplo n.º 7
0
VOID
FreeExit( LONG rc )
{
    if( Menus )
    {
        if( WindowPtr )
        {
            ClearMenuStrip( WindowPtr );
        }

        FreeMenus( Menus );
    }

    CloseGUI();

    if( Screen )
    {
        FreeScreenDrawInfo( Screen, DrawInfo );
        UnlockPubScreen (NULL, Screen );
    }

    if( GadToolsBase )
    {
        FreeVisualInfo( VisualInfo );
    }

    if( FileReq )
    {
        rtFreeRequest( FileReq );
    }

    if( DiskObject )
    {
        FreeDiskObject( DiskObject );
    }

    FreeArgs( RDArgs );
    FreeLocale();

    CloseLib( GadToolsBase );
    CloseLib( IconBase );
    CloseLib( IntuitionBase );
    CloseLib( ReqToolsBase );
    CloseLib( UtilityBase );

    CloseLibrary( ( struct Library * ) GfxBase );
    __exit( rc );
}
Exemplo n.º 8
0
void detach_menu(struct Window *window)
{
#if 1
	delete_appwindow();
#endif

	if (menu)
	{
		while (spawn_count)
		{
			Printf("You need to close requester windows\ncan't remove menu from mplayer, yet\n");
			Delay(1);
		}

		ClearMenuStrip(window);
		FreeMenus( menu );
		menu = NULL;
	}
}
Exemplo n.º 9
0
static struct Menu *createViewerDisplayMenu(struct Screen *screen, const int previousItemEnabled, const int nextItemEnabled)
{
    /* Get some visual info required to properly generate the menu layout */
    APTR vi = GetVisualInfo(screen, TAG_END);
    
    if(vi == NULL)
    {
	fprintf(stderr, "Cannot obtain visual info!\n");
	return NULL;
    }
    else
    {
	/* Create a menu */
	
	struct NewMenu newMenu[] = {
	    {NM_TITLE, "Picture", 0, 0, 0, 0},
	    {NM_ITEM, "Open...", "O", 0, 0, 0},
	    {NM_ITEM, "Previous", "P", previousItemEnabled ? 0 : NM_ITEMDISABLED, 0, 0},
	    {NM_ITEM, "Next", "N", nextItemEnabled ? 0 : NM_ITEMDISABLED, 0, 0},
	    {NM_ITEM, "Hide Title", "S", CHECKIT | MENUTOGGLE, 0, 0},
	    {NM_ITEM, "Cycle", "C", CHECKIT | MENUTOGGLE, 0, 0},
	    {NM_ITEM, "Quit", "Q", 0, 0, 0},
	    {NM_END, NULL, 0, 0, 0, 0}
	};
	
	struct Menu *menu = CreateMenus(newMenu, GTMN_FullMenu, TRUE, TAG_END);
	
	if(menu != NULL)
	{
	    /* Properly layout the menu items */
	    if(!LayoutMenus(menu, vi, TAG_END))
	    {
		fprintf(stderr, "Cannot calculate menu layout!\n");
		FreeMenus(menu);
		menu = NULL;
	    }
	}
	
	FreeVisualInfo(vi); /* Cleanup */
	
	return menu; /* Return generated menu */
    }
}
Exemplo n.º 10
0
static void Cleanup(void)
{
   /* do not handle this signal when cleaning up */
   signal(SIGWINCH, SIG_IGN);

   if(GameMode)
      glutLeaveGameMode();

   if(ConsoleFD != -1)
      RestoreVT();

   /* close mouse */
   CloseMouse();

   if(Visual)
      glutDestroyWindow(1);

   /* restore original variable screen info */
   if(FrameBufferFD != -1) {
      OrigVarInfo.xoffset = 0;
      OrigVarInfo.yoffset = 0;

      if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo))
	 fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
		 strerror(errno));

      if(FrameBuffer)
         munmap(FrameBuffer, FixedInfo.smem_len);
      close(FrameBufferFD);

   }

   /* free allocated back buffer */
   if(DisplayMode & GLUT_DOUBLE)
      free(BackBuffer);

   /* free menu items */
   FreeMenus();

   if(exiterror[0])
      fprintf(stderr, "[glfbdev glut] %s", exiterror);
 }
Exemplo n.º 11
0
void CloseGUI(void) {

  if(savereq) DisposeObject(savereq);
  if(openreq) DisposeObject(openreq);

  savereq   = NULL;
  openreq   = NULL;

  if(WO_Window) DisposeObject(WO_Window);

  WO_Window = NULL;
  Window    = NULL;

  /* Dynamic */
  if(unitlist)     FreeChooserLabels(unitlist);
  if(modelist)     FreeBrowserNodes(modelist);
  if(infolist)     FreeBrowserNodes2(infolist);

  /* Static */
  if(pagelist)     FreeClickTabs(pagelist);
  if(debuglist)    FreeChooserLabels(debuglist);
  if(echolist)     FreeChooserLabels(echolist);
  if(surroundlist) FreeChooserLabels(surroundlist);
  if(clipMVlist)   FreeChooserLabels(clipMVlist);

  unitlist = modelist = infolist =
  pagelist = debuglist = echolist = surroundlist = clipMVlist = NULL;

  if(Menu) FreeMenus(Menu);

  Menu = NULL;

  if(vi) FreeVisualInfo(vi);

  vi = NULL;

  if(infotext) FreeVec(infotext);

  infotext = NULL;

}
Exemplo n.º 12
0
/* rsrc_exit();
 * ================================================================
 */
void
rsrc_exit( void )
{
   /* Free up the DATA Buffer */
   if( data_buffer )
      Mfree( data_buffer );
    data_buffer = NULL;

   /* Close up and Free all the windows */
   if( wid > 0 )
   {
     wind_close( wid );
     wind_delete( wid );
   }

   /* Free up the Resource */
   rsrc_free();

   /* Free up the SubMenus and Popups */
   FreeMenus();
}
Exemplo n.º 13
0
void CBDCApp::DrawBirthday(CBirthday *pbd)
{
	struct list_entry_t ple;

	trillianListInitialize(ple);

	ple.previous_id		= -2; 
	ple.section_id		= m_sectionID;
	ple.unique_id		= -1; 
	ple.group			= 0;
	ple.section			= 0; 
	ple.inline_editing	= 0;
	ple.drag_and_drop	= 0; 
	ple.expanded		= 1; 
	ple.callback		= ::listCallback;

	AssignString(&ple.tooltip, pbd->GetTooltip());
	ASSERT(m_pproc);
	if( m_pproc )
	{
		AssignString(&ple.text, pbd->GetText(m_pproc->GetSuffix(), m_pproc->DrawLeftInfo()));
	}
	else
	{
		AssignString(&ple.text, pbd->GetText(SUFFIX_NONE));
	}

	ple.data			= (void*)pbd;

	// icon
	MakeIconLeft( &ple, pbd->m_confirmed?1:0);

	// right icon
	MakeIconRight( &ple, pbd->m_medium);

	if(pbd->m_date.IsDateOfYear())
	{
		ple.font.flags = 0x1;
		ple.font.skin_name = "recent-online";
		ple.font.select_fore = "recent-online-fore";
		ple.font.hover_fore = "recent-online-fore";
		ple.font.normal_fore = "recent-online-fore";
	}

	AddMenu(MENU_EDIT, "&Edit...", &ple.menu_entry, pbd);
	AddMenu(MENU_CONFIRM, "&Confirm...", &ple.menu_entry, pbd);
	AddMenu(MENU_REMOVE, "&Remove...", &ple.menu_entry, pbd);

	if( pbd->m_medium == MEDIUM_ICQ )
	{
		AddMenu(MENU_RELOAD, "&Reload...", &ple.menu_entry, pbd);
	}

	// You'll need the UniqueID for any further manipulation, so store it somewhere nice
	pbd->m_listid_bd = m_plugin_send(MYGUID, "listAddEntry", (void *)&ple);

	// Free what needs to be freed
	FreeMenus(&ple.menu_entry);
	free(ple.text);
	free(ple.tooltip);
	FreeIcons(&ple);
}
Exemplo n.º 14
0
void CBDCApp::DrawKnown(CBirthday *pbd, bool bSorted/*=true*/)
{
	struct list_entry_t ple;

	trillianListInitialize(ple);

	ple.section_id		= m_sectionID;
	ple.parent_id		= m_knowngroupID;
	ple.unique_id		= -1; 
	ple.group			= 0;
	ple.section			= 0; 
	ple.inline_editing	= 0;
	ple.drag_and_drop	= 0; 
	ple.expanded		= 1; 
	ple.callback		= ::listCallback;

	ASSERT( m_pproc );
	if( bSorted && m_pproc )
		ple.previous_id	= m_pproc->GetPreviousID(pbd);
	else
		ple.previous_id	= -1;

	AssignString(&ple.tooltip, pbd->GetTooltip());
	ASSERT(m_pproc);
	if( m_pproc )
	{
		AssignString(&ple.text, pbd->GetText(m_pproc->GetSuffix(), m_pproc->DrawLeftInfo()));
	}
	else
	{
		AssignString(&ple.text, pbd->GetText(SUFFIX_NONE));
	}

	ple.data			= (void*)pbd;

	// left icon
	ple.left_icons		= (struct list_bmp_t *)malloc(sizeof(struct list_bmp_t));
	trillianInitialize((*ple.left_icons));
	
	ple.left_icons->num_states	= 1;

	ple.left_icons->bitmap		= (HBITMAP *)malloc(sizeof(HBITMAP));
	ple.left_icons->bitmap[0]	= m_pbmpListentry_known;

	ple.left_icons->location	= (RECT *)malloc(sizeof(RECT));
	ple.left_icons->location[0].left	=  0;
	ple.left_icons->location[0].top		=  0;
	ple.left_icons->location[0].bottom	= 18;
	ple.left_icons->location[0].right	= 18;

	ple.num_left_icons = 1;

	// right icon
	MakeIconRight( &ple,
		pbd->m_medium);

	AddMenu(MENU_ADD, "&Add...", &ple.menu_entry);
	AddMenu(MENU_EDIT, "&Edit...", &ple.menu_entry, pbd);
	AddMenu(MENU_REMOVE, "&Remove...", &ple.menu_entry, pbd);

	if( pbd->m_medium == MEDIUM_ICQ )
	{
		AddMenu(MENU_RELOAD, "Re&load...", &ple.menu_entry, pbd);
	}

	// You'll need the UniqueID for any further manipulation, so store it somewhere nice
	pbd->m_listid_known = m_plugin_send(MYGUID, "listAddEntry", (void *)&ple); 

	FreeMenus(&ple.menu_entry);
	free(ple.text);
	free(ple.tooltip);
	FreeIcons(&ple);
}
Exemplo n.º 15
0
STATIC BOOL FOGadInit(struct LayoutData *ld, struct AslBase_intern *AslBase)
{    
    struct FOUserData 	*udata = ld->ld_UserData;
    struct IntFontReq 	*iforeq = (struct IntFontReq *)ld->ld_IntReq;
    STRPTR 		str[6];
#if USE_SHARED_COOLIMAGES
    struct ButtonInfo 	bi[NUMBUTS] =
    {
        { ID_BUTOK	, GetIR(iforeq)->ir_PositiveText , MSG_FONTREQ_POSITIVE_GAD, COOL_USEIMAGE_ID    , &udata->OKBut	  },
	{ ID_BUTCANCEL  , GetIR(iforeq)->ir_NegativeText , MSG_FONTREQ_NEGATIVE_GAD, COOL_CANCELIMAGE_ID , &udata->CancelBut  }
    };
#else
    struct ButtonInfo 	bi[NUMBUTS] =
    {
        { ID_BUTOK	, GetIR(iforeq)->ir_PositiveText , MSG_FONTREQ_POSITIVE_GAD, &cool_useimage    , &udata->OKBut	  },
	{ ID_BUTCANCEL  , GetIR(iforeq)->ir_NegativeText , MSG_FONTREQ_NEGATIVE_GAD, &cool_cancelimage , &udata->CancelBut  }
    };
#endif
    Object 		*gad;
    LONG		error;
    WORD 		gadrows, x, y, w, h, i, y2;
    WORD		sizelvwidth, labelwidth = 0, maxgadcolwidth = 0;
    
    NEWLIST(&udata->NameListviewList);

    udata->SizeListviewRenderHook.h_Entry      = (APTR)AROS_ASMSYMNAME(SizeListviewRenderFunc);
    udata->SizeListviewRenderHook.h_SubEntry   = NULL;
    udata->SizeListviewRenderHook.h_Data       = AslBase;

    udata->StringEditHook.h_Entry    = (APTR)AROS_ASMSYMNAME(StringEditFunc);
    udata->StringEditHook.h_SubEntry = NULL;
    udata->StringEditHook.h_Data     = AslBase;

    FOGetFonts(ld, AslBase);
    
    error = ERROR_NO_FREE_STORE;
    
    /* calc. min. size */

    w = 0;
    for(i = 0; i < NUMBUTS; i++)
    {
    	if(!bi[i].text) bi[i].text = GetString(bi[i].deftextid, GetIR(iforeq)->ir_Catalog, AslBase);

        x = TextLength(&ld->ld_DummyRP, bi[i].text, strlen(bi[i].text));

#if FOREQ_COOL_BUTTONS
#if USE_SHARED_COOLIMAGES
    	if (CoolImagesBase)
	{
	    bi[i].coolimage = (const struct CoolImage *)COOL_ObtainImageA(bi[i].coolid, NULL);
	}
	
	if (CoolImagesBase)
#endif
	if (ld->ld_TrueColor)
	{
	    x += IMAGEBUTTONEXTRAWIDTH + bi[i].coolimage->width;
	}
#endif

	if (x > w) w = x;	
    }
    
    udata->ButWidth = w + BUTTONEXTRAWIDTH;

    ld->ld_ButWidth = udata->ButWidth;
    ld->ld_NumButtons = 4;
    
#if FOREQ_COOL_BUTTONS

#if USE_SHARED_COOLIMAGES
    if (CoolImagesBase)
    {
#endif
	y  = BUTTONEXTRAHEIGHT + ld->ld_Font->tf_YSize;
	if (ld->ld_TrueColor)
	{
            y2 = IMAGEBUTTONEXTRAHEIGHT + DEF_COOLIMAGEHEIGHT;
	} else {
            y2 = 0;
	}
	udata->ButHeight = (y > y2) ? y : y2;
#if USE_SHARED_COOLIMAGES
    }
    else
    {
    	udata->ButHeight = BUTTONEXTRAHEIGHT + ld->ld_Font->tf_YSize;
    }
#endif

#else
    udata->ButHeight = BUTTONEXTRAHEIGHT + ld->ld_Font->tf_YSize;
#endif
    
    gadrows = 2; /* button row + string gadgets under listviews */
    if (iforeq->ifo_Flags & FOF_DODRAWMODE) gadrows++;
    if (iforeq->ifo_Flags & FOF_DOSTYLE) gadrows++;
    if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN)) gadrows++;
    
    ld->ld_MinWidth =  OUTERSPACINGX * 2 +
		       GADGETSPACINGX * 1 +
		       udata->ButWidth * NUMBUTS;

    ld->ld_MinHeight = OUTERSPACINGY * 2 +
		       (GADGETSPACINGY + udata->ButHeight) * gadrows +
		       BORDERLVSPACINGY * 2 +
		       (ld->ld_Font->tf_YSize + BORDERLVITEMSPACINGY * 2) * FOREQ_MIN_VISIBLELINES +
		       FONTPREVIEWHEIGHT + GADGETSPACINGY -
		       GADGETSPACINGY; /* because the string gadgets are attached to listview gadgets */

    /* make listview gadgets */
    
    sizelvwidth = PROPSIZE +
    	    	  FOREQ_VISIBILE_SIZE_CHARS * ld->ld_Font->tf_XSize +
		  BORDERLVSPACINGX * 2 +
		  BORDERLVITEMSPACINGX * 2;
    
    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = ld->ld_WBorTop + OUTERSPACINGY;
    w = -ld->ld_WBorRight - ld->ld_WBorLeft - OUTERSPACINGX * 2 - PROPSIZE - GADGETSPACINGX - sizelvwidth;
    h = -ld->ld_WBorBottom - ld->ld_WBorTop - OUTERSPACINGY * 2 -
    	udata->ButHeight * gadrows -
	GADGETSPACINGY * gadrows -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) +
	GADGETSPACINGY; /* because the string gadgets are attached to listview gadgets */
    
    {
        struct TagItem lv_tags[] = 
	{
	    {GA_Left		, x						},
	    {GA_Top		, y						},
	    {GA_RelWidth	, w						},
	    {GA_RelHeight	, h						},
	    {GA_UserData	, (IPTR)ld					},
	    {GA_ID		, ID_NAMELISTVIEW				},
	    {GA_RelVerify	, TRUE						},
	    {ASLLV_Labels	, (IPTR)&udata->NameListviewList		},
	    {TAG_IGNORE    	, 0 	    	    	    	    	    	},
	    {TAG_IGNORE     	, (IPTR)&udata->SizeListviewRenderHook	    	},
	    {ASLLV_Font     	, (IPTR)ld->ld_Font 	    	    	    	},
	    {TAG_DONE								}
	};
	
	udata->NameListview = gad = NewObjectA(AslBase->asllistviewclass, NULL, lv_tags);
	if (!gad) goto failure;

    	lv_tags[0].ti_Tag  = GA_RelRight;
	lv_tags[0].ti_Data = -ld->ld_WBorRight - OUTERSPACINGX - sizelvwidth + 1;
	lv_tags[2].ti_Tag  = GA_Width;
	lv_tags[2].ti_Data = sizelvwidth - PROPSIZE;
	lv_tags[5].ti_Data = ID_SIZELISTVIEW;
	lv_tags[7].ti_Data = 0;
	lv_tags[8].ti_Tag  = GA_Previous;
	lv_tags[8].ti_Data = (IPTR)gad;
	lv_tags[9].ti_Tag  = ASLLV_CallBack;
	
	udata->SizeListview = gad = NewObjectA(AslBase->asllistviewclass, NULL, lv_tags);
	if (!gad) goto failure;
	
    }
    
    /* make scroller gadgets for listviews */
    		       
    x = -ld->ld_WBorRight - OUTERSPACINGX - PROPSIZE - sizelvwidth - GADGETSPACINGX + 1;
    y = ld->ld_WBorTop + OUTERSPACINGY;
    w = PROPSIZE;
    h = -ld->ld_WBorBottom - ld->ld_WBorTop - OUTERSPACINGY * 2 -
    	udata->ButHeight * gadrows -
	GADGETSPACINGY * gadrows -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) +
	GADGETSPACINGY;
    {
	struct TagItem scroller_tags[] =
	{
    	    {GA_RelRight	, x		    },
	    {GA_Top		, y		    },
	    {GA_Width		, w		    },
	    {GA_RelHeight	, h		    },
	    {GA_ID		, ID_NAMELISTVIEW   },
	    {PGA_NewLook	, TRUE		    },
	    {PGA_Borderless 	, TRUE		    },
	    {PGA_Freedom	, FREEVERT	    },
	    {PGA_Top		, 0		    },
	    {PGA_Total		, 20		    },
	    {PGA_Visible	, 1		    },
	    {GA_Previous	, (IPTR)gad	    },
	    {TAG_DONE				    }
	};

	if (!makescrollergadget(&udata->NameScrollGad, ld, scroller_tags, AslBase)) goto failure;
	gad = udata->NameScrollGad.arrow2;

    	scroller_tags[0].ti_Data  = x + sizelvwidth + GADGETSPACINGX;
	scroller_tags[1].ti_Data  = y;
	scroller_tags[2].ti_Data  = w;
	scroller_tags[3].ti_Data  = h;
	scroller_tags[4].ti_Data  = ID_SIZELISTVIEW;
	scroller_tags[11].ti_Data = (IPTR)gad;
	
	if (!makescrollergadget(&udata->SizeScrollGad, ld, scroller_tags, AslBase)) goto failure;
	gad = udata->SizeScrollGad.arrow2;
	
    }

    connectscrollerandlistview(&udata->NameScrollGad, udata->NameListview, AslBase);
    connectscrollerandlistview(&udata->SizeScrollGad, udata->SizeListview, AslBase);

    /* make preview gadget */

    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	GADGETSPACINGY - FONTPREVIEWHEIGHT;
    w = -ld->ld_WBorRight - ld->ld_WBorLeft - OUTERSPACINGX * 2;

    {
    	struct TagItem preview_tags[] =
	{
	    {GA_Left	    	, x 	    	    	    	    },
	    {GA_RelBottom   	, y 	    	    	    	    },
	    {GA_RelWidth    	, w 	    	    	    	    },
	    {GA_Height	    	, FONTPREVIEWHEIGHT  	    	    },
	    {GA_Previous    	, (IPTR)gad 	    	    	    },
	    {GA_ID  	    	, ID_PREVIEW     	    	    },
	    {ASLFP_SampleText	, (IPTR)iforeq->ifo_SampleText	    },
	    {ASLFP_APen     	, iforeq->ifo_FrontPen	    	    },
	    {ASLFP_BPen     	, iforeq->ifo_BackPen	    	    },
	    {TAG_DONE	    	    	    	    	    	    }
	};

	udata->Preview = gad = NewObjectA(AslBase->aslfontpreviewclass, NULL, preview_tags);
	if (!gad) goto failure;
    }
    
    /* make string gadgets */

    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	(udata->ButHeight + GADGETSPACINGY) * (gadrows - 1) -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) + 1;
		
    w = -ld->ld_WBorRight - ld->ld_WBorLeft - OUTERSPACINGX * 2 - GADGETSPACINGX - sizelvwidth;
    
    {
    	struct TagItem string_tags[] =
	{
	    {GA_Left	    	, x 	    	    	    	    },
	    {GA_RelBottom   	, y 	    	    	    	    },
	    {GA_RelWidth    	, w 	    	    	    	    },
	    {GA_Height	    	, udata->ButHeight  	    	    },
	    {GA_Previous    	, (IPTR)gad 	    	    	    },
	    {STRINGA_TextVal	, (IPTR)""     	    	    	    },
	    {STRINGA_MaxChars	, MAXFONTNAME 	    	    	    },
	    {STRINGA_EditHook	, (IPTR)&udata->StringEditHook	    },
	    {GA_ID  	    	, ID_NAMESTRING     	    	    },
	    {GA_RelVerify   	, TRUE	    	    	    	    },
	    {GA_UserData    	, (IPTR)ld  	    	    	    },
	    {GA_TabCycle    	, TRUE	    	    	    	    },
	    {STRINGA_Font   	, (IPTR)ld->ld_Font 	    	    },
	    {TAG_DONE	    	    	    	    	    	    }
	};

	udata->NameString = gad = NewObjectA(AslBase->aslstringclass, NULL, string_tags);
	if (!gad) goto failure;
	
   	string_tags[0].ti_Tag  = GA_RelRight;
	string_tags[0].ti_Data = -ld->ld_WBorRight - OUTERSPACINGX - sizelvwidth + 1;
	string_tags[2].ti_Tag  = GA_Width;
	string_tags[2].ti_Data = sizelvwidth;
	string_tags[4].ti_Data = (IPTR)gad;
	string_tags[5].ti_Tag  = STRINGA_LongVal;
	string_tags[5].ti_Data = iforeq->ifo_TextAttr.ta_YSize;
	string_tags[6].ti_Data = 6;
	string_tags[8].ti_Data = ID_SIZESTRING;

	udata->SizeString = gad = NewObjectA(AslBase->aslstringclass, NULL, string_tags);
	if (!gad) goto failure;
	
    }
    
    /* make button row */
    
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight + 1;
    
    {
        struct TagItem button_tags[] =
	{
	    {GA_Text		, 0			},
	    {GA_Previous	, 0			},
	    {GA_ID		, 0			},
#if FOREQ_COOL_BUTTONS
	    {ASLBT_CoolImage	, 0			},
#else
	    {TAG_IGNORE		, 0			},
#endif	    
	    {GA_UserData	, (IPTR)ld		},
	    {GA_Left		, 0			},
	    {GA_RelBottom	, y			},
	    {GA_Width		, udata->ButWidth	},
	    {GA_Height		, udata->ButHeight	},
	    {GA_RelVerify	, TRUE			},
	    {GA_Image		, 0			}, /* means we want a frame */
	    {TAG_DONE					}
	};

	for(i = 0; i < NUMBUTS; i++)
	{
	    button_tags[0].ti_Data = (IPTR)bi[i].text;
	    button_tags[1].ti_Data = (IPTR)gad;
	    button_tags[2].ti_Data = bi[i].gadid;
	#if USE_SHARED_COOLIMAGES
	    if (CoolImagesBase == NULL) button_tags[3].ti_Tag = TAG_IGNORE;
	#endif
	    button_tags[3].ti_Data = (IPTR)bi[i].coolimage;

	    *(bi[i].objvar) = gad = NewObjectA(AslBase->aslbuttonclass, NULL, button_tags);
	    if (!gad) goto failure;
	}
	 	 
    }	 
    
    /* make labels */
        
    i = 0;

    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	(udata->ButHeight + GADGETSPACINGY) * (gadrows - 2) -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) + 1;

    if (iforeq->ifo_Flags & (FOF_DODRAWMODE | FOF_DOSTYLE | FOF_DOFRONTPEN | FOF_DOBACKPEN))
    {
        #define FSET(x) ((iforeq->ifo_Flags & x) ? TRUE : FALSE)
	
        struct LabelInfo
	{
	    BOOL doit;
	    char *text;
	    Object **objvar;
	} li [] =
	{
	    {FSET(FOF_DOSTYLE)	    , (STRPTR)MSG_FONTREQ_STYLE_LABEL 	, &udata->StyleLabel     },
	    {FALSE  	    	    , (STRPTR)MSG_FONTREQ_COLOR_LABEL_FG, &udata->ColorLabel	 },
	    {FSET(FOF_DODRAWMODE)   , (STRPTR)MSG_FONTREQ_MODE_LABEL  	, &udata->DrawModeLabel  }
	}; 

        #undef FSET
	
        struct TagItem label_tags[] =
	{
	    {GA_Left		, 0			},
	    {GA_RelBottom	, y			},
	    {GA_Width		, 0			},
	    {GA_Height		, udata->ButHeight	},
	    {GA_Text		, 0			},
	    {GA_Previous	, (IPTR)gad		},
	    {GA_UserData	, (IPTR)ld		},
	    {GA_Disabled	, TRUE			},
	    {TAG_DONE					}
	};
    	WORD i2;
	
	if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	{
	    li[1].doit = TRUE;
	    
	    switch(iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	    {
	    	case FOF_DOFRONTPEN:
		    break;
		    
		case FOF_DOBACKPEN:
		    li[1].text = (STRPTR)MSG_FONTREQ_COLOR_LABEL_BG;
		    break;
		    
		case FOF_DOFRONTPEN | FOF_DOBACKPEN:
		    li[1].text = (STRPTR)MSG_FONTREQ_COLOR_LABEL_FGBG;
		    break;
	    }
	    
	} /* if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN)) */
    	for(i = 0, i2 = 0; i < 3; i++)
	{
	    if (li[i].doit)
	    {
	    	if ((i == 2) && (iforeq->ifo_ModeList))
		{
		    li[i].text = iforeq->ifo_ModeList[0];
		}
		else
		{
	    	    li[i].text = GetString((LONG)li[i].text, GetIR(iforeq)->ir_Catalog, AslBase);
		}
		str[i2++] = li[i].text;
	    }
	}
		
	w = labelwidth = BiggestTextLength(str, i2, &(ld->ld_DummyRP), AslBase);
            
	for(i = 0; i < 3;i++)
	{
	    if (!li[i].doit) continue;
	    
	    label_tags[2].ti_Data = TextLength(&ld->ld_DummyRP, li[i].text, strlen(li[i].text));
	    label_tags[0].ti_Data = x + w - label_tags[2].ti_Data;
	    label_tags[4].ti_Data = (IPTR)li[i].text;
	    label_tags[5].ti_Data = (IPTR)gad;
	    
	    *(li[i].objvar) = gad = NewObjectA(AslBase->aslbuttonclass, NULL, label_tags);
	    if (!gad) goto failure;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	    label_tags[1].ti_Data = y;
	}	

    	y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	    (udata->ButHeight + GADGETSPACINGY) * (gadrows - 2) -
	    (FONTPREVIEWHEIGHT + GADGETSPACINGY) + 1;
	    
	x = ld->ld_WBorLeft + OUTERSPACINGX + w + LABELSPACINGX;

    	/* Make Style gadget */
	
	if (iforeq->ifo_Flags & FOF_DOSTYLE)
	{
	    STRPTR stylestrings[3];
	    
	    struct TagItem style_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_Width		, 0				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_STYLE			  },
		{ASLFS_LabelArray    	, (IPTR)stylestrings	    	  },
		{ASLFS_Style		, iforeq->ifo_TextAttr.ta_Style	  },
		{TAG_DONE						  }
	    };

    	    stylestrings[0] = GetString(MSG_FONTREQ_STYLE_BOLD, GetIR(iforeq)->ir_Catalog, AslBase);
    	    stylestrings[1] = GetString(MSG_FONTREQ_STYLE_ITALIC, GetIR(iforeq)->ir_Catalog, AslBase);
    	    stylestrings[2] = GetString(MSG_FONTREQ_STYLE_UNDERLINED, GetIR(iforeq)->ir_Catalog, AslBase);
	    
	    w = BiggestTextLength(stylestrings, 3, &(ld->ld_DummyRP), AslBase);
	    w *= 2;
	    w *= 3;
	    
	    style_tags[3].ti_Data = w;
	    
	    if (w > maxgadcolwidth) maxgadcolwidth = w;
	    
	    udata->StyleGadget = gad = NewObjectA(AslBase->aslfontstyleclass, NULL, style_tags);
	    if (!gad) goto failure;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	    
	}
	
	w = udata->ButHeight * 12 / 10 + 19; /* CYCLEIMAGEWIDTH = 19 */
	
	/* Make FrontPen gadget */
	
	if (iforeq->ifo_Flags & FOF_DOFRONTPEN)
	{
	    struct TagItem cp_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_Width		, w				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_FRONTPEN			  },
		{ASLCP_Color	    	, iforeq->ifo_FrontPen	    	  },
		{ASLCP_ColorTable   	, (IPTR)iforeq->ifo_FrontPens     },
		{ASLCP_NumColors    	, iforeq->ifo_MaxFrontPen   	  },
		{TAG_DONE						  }
		
	    };
	    
	    udata->FGColorGadget = gad = NewObjectA(AslBase->aslcolorpickerclass, NULL, cp_tags);
	    if (!gad) goto failure;
	    
	    x += w + GADGETSPACINGX;
	}

    	/* Make BackPen gadget */
	
	if (iforeq->ifo_Flags & FOF_DOBACKPEN)
	{
	    struct TagItem cp_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_Width		, w				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_BACKPEN			  },
		{ASLCP_Color	    	, iforeq->ifo_BackPen	    	  },
		{ASLCP_ColorTable   	, (IPTR)iforeq->ifo_BackPens      },
		{ASLCP_NumColors    	, iforeq->ifo_MaxBackPen   	  },
		{TAG_DONE						  }
		
	    };
	    
	    udata->BGColorGadget = gad = NewObjectA(AslBase->aslcolorpickerclass, NULL, cp_tags);
	    if (!gad) goto failure;
	    
	}

    	if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	{
	    if ((iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN)) == (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	    {
	    	w += GADGETSPACINGX + w;
	    }
	    
	    if (w > maxgadcolwidth) maxgadcolwidth = w;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	}
	
	
    	/* Make DrawMode gadget */

	x = ld->ld_WBorLeft + OUTERSPACINGX + labelwidth + LABELSPACINGX;

	w = -ld->ld_WBorLeft - ld->ld_WBorRight - OUTERSPACINGX * 2 -
            labelwidth - LABELSPACINGX;

	
	if (iforeq->ifo_Flags & FOF_DODRAWMODE)
	{
	    struct TagItem cycle_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_RelWidth		, w				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_DRAWMODE			  },
		{ASLCY_Labels		, 0 	    	    	    	  },
		{ASLCY_Active		, iforeq->ifo_DrawMode	    	  },
		{ASLCY_Font 	    	, (IPTR)ld->ld_Font 	    	  },
		{TAG_DONE						  }
		
	    };
	    static LONG labelids[] =
	    {
		MSG_FONTREQ_MODE_TEXT,
		MSG_FONTREQ_MODE_TEXTANDFIELD,
		MSG_FONTREQ_MODE_COMPLEMENT,
	    };
	    STRPTR *labels;
	    
	    
	    if (iforeq->ifo_ModeList)
	    {
	    	labels = &iforeq->ifo_ModeList[1];
	    }
	    else
	    {
    	    	labels = (STRPTR *)&iforeq->ifo_DrawModeJAM1Text;
	    	
    		for(i = 0; i < 3; i++)
		{
	    	    labels[i] = GetString(labelids[i], GetIR(iforeq)->ir_Catalog, AslBase);
		}
	    }
	    
	    cycle_tags[8].ti_Data = (IPTR)labels;
	    
	    i = CYCLEEXTRAWIDTH +  BiggestTextLength(labels,
	    					     0x7FFF,
						     &(ld->ld_DummyRP),
						     AslBase);						     
	    if (i > maxgadcolwidth) maxgadcolwidth = i;
	    
	    udata->DrawModeGadget = gad = NewObjectA(AslBase->aslcycleclass, NULL, cycle_tags);
	    if (!gad) goto failure;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	    
	} /* if (iforeq->ifo_Flags & FOF_DODRAWMODE) */
		
    } /* if (iforeq->ifo_Flags & (FOF_DODRAWMODE | FOF_DOSTYLE | FOF_DOFRONTPEN | FOF_DOBACKPEN)) */

#if AVOID_FLICKER
    {
    	struct TagItem eraser_tags[] =
	{
	    {GA_Previous, (IPTR)gad},
	    {TAG_DONE}
	};
	
	udata->EraserGadget = gad = NewObjectA(AslBase->asleraserclass, NULL, eraser_tags);
	/* Doesn't matter if this failed */
    }
#endif
    
    w = OUTERSPACINGX + labelwidth + LABELSPACINGX + maxgadcolwidth + OUTERSPACINGX;
    if (w > ld->ld_MinWidth) ld->ld_MinWidth = w;
    
    ld->ld_GList = (struct Gadget *)udata->NameListview;							 
    
    /* Menus */
    {
        struct NewMenu nm[] =
	{
	    {NM_TITLE, (STRPTR)MSG_FONTREQ_MEN_CONTROL							},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_LASTFONT , 0, 0, 0, (APTR)FOMEN_LASTFONT		},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_NEXTFONT , 0, 0, 0, (APTR)FOMEN_NEXTFONT 	},
	     {NM_ITEM, NM_BARLABEL									},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_RESTORE	, 0, 0, 0, (APTR)FOMEN_RESTORE 		},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_RESCAN	, 0, 0, 0, (APTR)FOMEN_RESCAN		},
	     {NM_ITEM, NM_BARLABEL									},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_OK   	, 0, 0, 0, (APTR)FOMEN_OK		},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_CANCEL	, 0, 0, 0, (APTR)FOMEN_CANCEL		},
	    {NM_END																}
	};

	struct TagItem menu_tags[] =
	{
	    {GTMN_NewLookMenus  , TRUE  	    	    	    },
	    {GTMN_TextAttr	, (IPTR)GetIR(iforeq)->ir_TextAttr  },
	    {TAG_DONE   	    	    	    	    	    }
	};
	
	if (menu_tags[1].ti_Data == 0) menu_tags[1].ti_Tag = TAG_IGNORE;

	LocalizeMenus(nm, GetIR(iforeq)->ir_Catalog, AslBase);

	/* Don't fail, if menus cannot be created/layouted, because a requester
	   without menus is still better than no requester at all */
	   
	if ((ld->ld_Menu = CreateMenusA(nm, NULL)))
	{
	    if (!LayoutMenusA(ld->ld_Menu, ld->ld_VisualInfo, menu_tags))
	    {
	        FreeMenus(ld->ld_Menu);ld->ld_Menu = NULL;
	    }
	}
    }
    
    FORestore(ld, iforeq->ifo_TextAttr.ta_Name, iforeq->ifo_TextAttr.ta_YSize,  AslBase);
    
    SetIoErr(0);
    ReturnBool ("FOGadInit", TRUE);
    
failure:
    SetIoErr(error);
    
    D(bug("failure\n"));

    FOGadCleanup(ld, ASLB(AslBase));

    ReturnBool ("FOGadInit", FALSE);

}