home *** CD-ROM | disk | FTP | other *** search
- /*
- ** GadTools layout toolkit
- **
- ** Copyright © 1993-1996 by Olaf `Olsen' Barthel
- ** Freely distributable.
- **
- ** :ts=4
- */
-
- #ifndef _GTLAYOUT_GLOBAL_H
- #include "gtlayout_global.h"
- #endif
-
- /****** gtlayout.library/LT_Init ******************************************
- *
- * NAME
- * LT_Init -- Initialize user interface code.
- *
- * SYNOPSIS
- * LT_Init();
- *
- * VOID LT_Init(VOID);
- *
- * FUNCTION
- * You need to initialize the user interface code only once,
- * so it can set up its internals, open libraries, etc.
- * The code has to be initialized before any user interface
- * creation can take place.
- *
- * NOTES
- * This function is not present in the shared library, only
- * in the link library. You need not and cannot invoke it in
- * the shared library.
- *
- * SEE ALSO
- * gtlayout.library/LT_Exit
- *
- ******************************************************************************
- *
- */
-
- BOOL LIBENT
- LT_Init()
- {
- #ifndef LINK_LIB
- SysBase = *(struct ExecBase **)4;
- #endif // LINK_LIB
-
- if(SysBase->LibNode.lib_Version < 37)
- return(FALSE);
- else
- {
- STATIC struct { STRPTR Name; APTR *Library; } InitTable[] =
- {
- "intuition.library", (APTR *)&IntuitionBase,
- "graphics.library", (APTR *)&GfxBase,
- "utility.library", (APTR *)&UtilityBase,
- "gadtools.library", (APTR *)&GadToolsBase,
- "keymap.library", (APTR *)&KeymapBase,
- "locale.library", (APTR *)&LocaleBase
- };
-
- STATIC struct { STRPTR ClassName; LONG Size; HOOKFUNC Dispatcher; Class **ClassPtr; } ClassInitTable[] =
- {
- IMAGECLASS, sizeof(ImageInfo), (HOOKFUNC)LTP_ImageDispatch, <P_ImageClass,
-
- #ifdef DO_LEVEL_KIND
- IMAGECLASS, sizeof(LevelImageInfo), (HOOKFUNC)LTP_LevelClassDispatcher, <P_LevelClass,
- #endif /* DO_LEVEL_KIND */
-
- #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
- GADGETCLASS, sizeof(PopInfo), (HOOKFUNC)LTP_PopupClassDispatcher, <P_PopupClass,
- #endif /* DO_POPUP_KIND */
-
- #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
- GADGETCLASS, sizeof(TabInfo), (HOOKFUNC)LTP_TabClassDispatcher, <P_TabClass,
- #endif /* DO_TAB_KIND */
-
- };
-
- LONG i;
-
- V39 = (SysBase->LibNode.lib_Version >= 39);
- V40 = (SysBase->LibNode.lib_Version >= 40);
-
- for(i = 0 ; i < NUMELEMENTS(InitTable) ; i++)
- *InitTable[i].Library = OpenLibrary(InitTable[i].Name,37);
-
- if(IntuitionBase && GfxBase && UtilityBase && GadToolsBase && KeymapBase)
- {
- if(LocaleBase)
- LTP_Locale = OpenLocale(NULL);
-
- for(i = 0 ; i < NUMELEMENTS(ClassInitTable) ; i++)
- {
- if(*ClassInitTable[i].ClassPtr = MakeClass(NULL,ClassInitTable[i].ClassName,NULL,ClassInitTable[i].Size,0))
- (*ClassInitTable[i].ClassPtr)->cl_Dispatcher.h_Entry = ClassInitTable[i].Dispatcher;
- else
- {
- LT_Exit();
- return(FALSE);
- }
- }
-
- #ifdef DO_PICKSHORTCUTS
- InitSemaphore(<P_KeySemaphore);
-
- if(!(LTP_Keys[0] = (UBYTE *)AllocMem(512,MEMF_ANY|MEMF_CLEAR)))
- {
- LT_Exit();
- return(FALSE);
- }
- #endif /* DO_PICKSHORTCUTS */
-
- InitSemaphore(<P_LockSemaphore);
-
- NewList((struct List *)<P_LockList);
- NewList((struct List *)<P_EmptyList);
-
- return(TRUE);
- }
-
- LT_Exit();
- return(FALSE);
- }
- }
-
-
- /*****************************************************************************/
-
-
- /****** gtlayout.library/LT_Exit ******************************************
- *
- * NAME
- * LT_Exit -- Clean up user interface allocations
- *
- * SYNOPSIS
- * LT_Exit();
- *
- * VOID LT_Exit(VOID);
- *
- * FUNCTION
- * When you are finished with user interface creation and
- * do not not need the code any more you should call this
- * routine. It will free all the memory allocated by
- * LT_Init(), close libraries, etc.
- *
- * INPUTS
- * none
- *
- * RESULT
- * none
- *
- * NOTES
- * This function is not present in the shared library, only
- * in the link library. You need not and cannot invoke it in
- * the shared library.
- *
- * SEE ALSO
- * gtlayout.library/LT_Init
- *
- ******************************************************************************
- *
- */
-
- VOID LIBENT
- LT_Exit()
- {
- if(SysBase && SysBase->LibNode.lib_Version >= 37)
- {
- #ifdef DO_PICKSHORTCUTS
- FreeMem(LTP_Keys[0],512);
- LTP_Keys[0] = LTP_Keys[1] = NULL;
- #endif
-
- #ifdef DO_LEVEL_KIND
- if(LTP_LevelClass)
- {
- FreeClass(LTP_LevelClass);
- LTP_LevelClass = NULL;
- }
- #endif /* DO_LEVEL_KIND */
-
- #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
- if(LTP_PopupClass)
- {
- FreeClass(LTP_PopupClass);
- LTP_PopupClass = NULL;
- }
- #endif // DO_POPUP_KIND
-
- #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
- if(LTP_TabClass)
- {
- FreeClass(LTP_TabClass);
- LTP_TabClass = NULL;
- }
- #endif // DO_TAB_KIND
-
- if(LTP_ImageClass)
- {
- FreeClass(LTP_ImageClass);
- LTP_ImageClass = NULL;
- }
-
- if(LTP_Locale)
- {
- CloseLocale(LTP_Locale);
- LTP_Locale = NULL;
- }
-
- CloseLibrary(LocaleBase);
- LocaleBase = NULL;
-
- CloseLibrary(KeymapBase);
- KeymapBase = NULL;
-
- CloseLibrary(GadToolsBase);
- GadToolsBase = NULL;
-
- CloseLibrary(UtilityBase);
- UtilityBase = NULL;
-
- CloseLibrary(GfxBase);
- GfxBase = NULL;
-
- CloseLibrary(IntuitionBase);
- IntuitionBase = NULL;
- }
- }
-