home *** CD-ROM | disk | FTP | other *** search
- head 1.70;
- access;
- symbols
- fontscreen:1.70
- good:1.60;
- locks; strict;
- comment @ * @;
-
-
- 1.70
- date 94.12.04.23.23.30; author jsshephe; state Exp;
- branches;
- next ;
-
-
- desc
- @original
- @
-
-
- 1.70
- log
- @Made the program reopen its interface on screenmode and font changes.
- @
- text
- @/*
- * GUI Designed by : -- Jeff Shepherd
- * #define TEST to use an internal test list
- *
- * $Id: showprefs.c,v 1.60 1994/12/04 02:37:31 jsshephe Exp jsshephe $
- * $Revision: 1.60 $
- * $Log: showprefs.c,v $
- * Revision 1.60 1994/12/04 02:37:31 jsshephe
- * Made the GUI font sensitive.
- * Made a few optimizations.
- *
- * Revision 1.57 1994/11/27 22:44:00 jsshephe
- * Changed GfxBase.
- * Added COPY gadget under listview.
- *
- * Revision 1.56 1994/08/19 01:35:17 jsshephe
- * fixed a stupid syntax error from v1.55
- *
- * Revision 1.55 1994/08/19 01:30:20 jsshephe
- * added version string
- *
- * Revision 1.54 1994/08/18 21:31:26 jsshephe
- * Made the preferences file use variable length strings instead of fixed length
- *
- * Revision 1.53 1994/08/18 18:41:05 jsshephe
- * Moved MakeNode() and DestroyList() to loadsave.c
- *
- * Revision 1.52 1994/08/18 06:28:39 jsshephe
- * Rearranged some things
- * Made the Test array conditionally compiled
- * At ALPHA test stage now
- *
- * Revision 1.51 1994/08/17 21:33:46 jsshephe
- * added zoom gadget
- * made a test list for the listview
- * had the string gadgets fill in when the appropriate list item was pressed
- *
- * Revision 1.5 1994/08/17 18:03:12 jsshephe
- * Added font sensitivity and layout recalculation based on font size
- *
- * Revision 1.2 1994/08/12 22:52:16 jsshephe
- * added main()
- *
- * Revision 1.1 1994/08/12 21:53:57 jsshephe
- * Initial revision
- * Constructed from GadtoolsBox
- */
-
- #define INTUI_V36_NAMES_ONLY
- /* #define TEST */
-
- #include <dos/dos.h>
- #include <dos/notify.h>
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <intuition/intuition.h>
- #include <intuition/gadgetclass.h>
- #include <libraries/gadtools.h>
- #include <graphics/gfxbase.h>
-
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/gadtools.h>
-
- #include <clib/alib_protos.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "showprefs.h"
-
- /* version string */
- char version[] = "\0$VER: Show Preferences program version 1.0";
- BOOL FromWB;
-
- #ifdef TEST
- /* for testing purposes only */
- /* constructs a dummy node list so I can save an initial prefs file */
- struct SuffixNode test[] = {
- "iff", "dsound -2 -f", TRUE,
- "ps", "gs", TRUE,
- "jpg", "utilities:viewtek/vt", TRUE,
- "gif", "utilities:viewtek/vt", TRUE
- };
- #endif
-
-
- /* protos */
- void panic(char *error, int retval);
- void ComputeGadgets(UWORD, UWORD);
- void CreateWindow();
- void DestroyWindow();
- #ifdef TEST
- struct List *MakeList(struct SuffixNode *, int);
- #endif
-
- struct IntuitionBase *IntuitionBase;
- struct Library *GadToolsBase, *AslBase, *IFFParseBase;
- struct GfxBase *GfxBase;
-
- struct Screen *Scr = NULL;
- APTR VisualInfo = NULL;
- struct Window *PrefsWnd = NULL;
- struct Gadget *PrefsGList = NULL;
- struct Menu *PrefsMenus = NULL;
- struct Gadget *PrefsGadgets[Prefs_CNT];
- UWORD PrefsLeft = 0;
- UWORD PrefsTop = 0;
- UWORD PrefsWidth = 400;
- UWORD PrefsHeight = 150;
- UBYTE *PrefsWdt = "Show Prefs";
- struct TextAttr Font;
- UWORD FontX, FontY;
- UWORD OffX, OffY;
-
- struct List *Suffix_List, *Duplicate;
-
-
- /* dimensions for Zoom- to be filled in later */
- UWORD Zoom[4] = {0,0,0,0};
-
- #define Prefs_TNUM 2
-
- /* Menus - has lookup table in userdata */
- struct NewMenu PrefsNewMenu[] = {
- NM_TITLE, "Project", NULL, 0, NULL, NULL,
- NM_ITEM, "Open...", "O", 0, 0L, (APTR)PrefsPREFS_OPEN,
- NM_ITEM, "Save As...", "A", 0, 0L, (APTR)PrefsPREFS_SAVEAS,
- NM_ITEM, "About", "B", 0, 0L, (APTR)PrefsPREFS_ABOUT,
- NM_ITEM, "Quit", "Q", 0, 0L, (APTR)PrefsPREFS_QUIT,
- NM_TITLE, "Edit", NULL, 0, NULL, NULL,
- NM_ITEM, "Last Saved", "L", 0, 0L, (APTR)PrefsPREFS_LAST,
- NM_ITEM, "Restore", "R", 0, 0L, (APTR)PrefsPREFS_RESTORE,
- NM_END, NULL, NULL, 0, 0L, NULL
- };
-
- UWORD PrefsGTypes[] = {
- BUTTON_KIND,
- STRING_KIND,
- STRING_KIND,
- CHECKBOX_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- LISTVIEW_KIND
- };
-
- /* heights and widths for gadgets are recomputed according to the font */
- /* numbers shown here reflect topaz 8 */
- struct NewGadget PrefsNGad[] = {
- 22, 197, 53, 24, "_Save", NULL, PREFS_SAVE, PLACETEXT_IN, NULL, (APTR)PREFS_SAVEClicked,
- 34, 77, 176, 22, "Su_ffix", NULL, -1, PLACETEXT_ABOVE, NULL, (APTR)PREFS_SUFFIXClicked,
- 34, 118, 176, 22, "Co_mmand", NULL, -1, PLACETEXT_ABOVE, NULL, (APTR)PREFS_COMMANDClicked,
- 35, 160, 26, 11, "Asynchronous", NULL, -1, PLACETEXT_RIGHT, NULL, (APTR)PREFS_ASYNCHClicked,
- 358, 197, 53, 24, "_Cancel", NULL, PREFS_CANCEL, PLACETEXT_IN, NULL, (APTR)PREFS_CANCELClicked,
- 237, 147, 53, 24, "_New", NULL, PREFS_NEW, PLACETEXT_IN, NULL, (APTR)PREFS_NEWClicked,
- 298, 147, 53, 24, "C_opy", NULL, PREFS_COPY, PLACETEXT_IN, NULL, (APTR)PREFS_COPYClicked,
- 358, 147, 53, 24, "_Del", NULL, PREFS_DELETE, PLACETEXT_IN, NULL, (APTR)PREFS_DELETEClicked,
- 187, 197, 53, 24, "_Use", NULL, PREFS_USE, PLACETEXT_IN, NULL, (APTR)PREFS_USEClicked,
- 237, 19, 140, 121,"Suffixes", NULL, PREFS_SUFFIXES, PLACETEXT_ABOVE, NULL, (APTR)PREFS_SUFFIXESClicked
- };
-
- ULONG PrefsGTags[] = {
- (GT_Underscore), '_', (TAG_DONE),
-
- (GTST_MaxChars), MAX_LENGTH, (STRINGA_Justification), (GACT_STRINGLEFT),
- (GT_Underscore), '_', (TAG_DONE),
-
- (GTST_MaxChars), MAX_LENGTH, (STRINGA_Justification), (GACT_STRINGLEFT),
- (GT_Underscore), '_', (TAG_DONE),
-
- (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (TAG_DONE)
- };
-
- #ifdef __GNUC__
- inline
- #endif
- UWORD ComputeX( UWORD value ) {
- return(( UWORD )((( FontX * value ) + (FontX >> 1) ) / FontX ));
- }
-
- #ifdef __GNUC__
- inline
- #endif
- UWORD ComputeY( UWORD value ) {
- return(( UWORD )((( FontY * value ) + (FontY >> 1 ) ) / FontY ));
-
- }
-
- /* find the length the gadget Buttons should be
- * bases its length on the length of "Cancel"
- * if "Cancel is not the longest gadget word, change Longest
- * Also recalculate the layout based on the font chosen
- */
- void ComputeGadgets(UWORD Width, UWORD Height) {
-
- static struct IntuiText IText[] = {
- 1, 0, JAM2, 115, 22, &Font, "Cancel ", NULL,
- 1, 0, JAM2, 115, 22, &Font, "Copy ", NULL
- };
-
- int len = IntuiTextLength(&IText[0]);
- int savelen = IntuiTextLength(&IText[1]);
- int height = 1.5*FontY;
-
- /* fill in zoom now */
- Zoom[2] = (Width >> 1);
- Zoom[3] = Scr->BarHeight;
-
- PrefsNGad[PREFS_NEW].ng_Width =
- PrefsNGad[PREFS_DELETE].ng_Width =
- PrefsNGad[PREFS_COPY].ng_Width = savelen;
-
- PrefsNGad[PREFS_USE].ng_Width =
- PrefsNGad[PREFS_SAVE].ng_Width =
- PrefsNGad[PREFS_CANCEL].ng_Width = len;
-
- PrefsNGad[PREFS_COMMAND].ng_Height =
- PrefsNGad[PREFS_SUFFIX].ng_Height =
- PrefsNGad[PREFS_NEW].ng_Height =
- PrefsNGad[PREFS_DELETE].ng_Height =
- PrefsNGad[PREFS_USE].ng_Height =
- PrefsNGad[PREFS_COPY].ng_Height =
- PrefsNGad[PREFS_SAVE].ng_Height =
- PrefsNGad[PREFS_CANCEL].ng_Height = height;
-
- /* Recompute Suffix listview width and height and top */
- PrefsNGad[PREFS_SUFFIXES].ng_Width = 140 *((float)FontX / 8);
- PrefsNGad[PREFS_SUFFIXES].ng_Height= 10*FontY;
- PrefsNGad[PREFS_SUFFIXES].ng_TopEdge = OffY + FontY;
-
- PrefsNGad[PREFS_SUFFIXES].ng_LeftEdge =
- PrefsNGad[PREFS_NEW].ng_LeftEdge = PrefsLeft + Width - (FontX << 1)-
- PrefsNGad[PREFS_SUFFIXES].ng_Width;
-
- /* Put the COPY, NEW, SAVE Gadgets right under the listview */
- PrefsNGad[PREFS_NEW].ng_TopEdge =
- PrefsNGad[PREFS_DELETE].ng_TopEdge =
- PrefsNGad[PREFS_COPY].ng_TopEdge = PrefsNGad[PREFS_SUFFIXES].ng_TopEdge +
- PrefsNGad[PREFS_SUFFIXES].ng_Height;
-
- PrefsNGad[PREFS_DELETE].ng_LeftEdge = PrefsLeft + Width -
- (FontX << 1) - savelen;
-
- PrefsNGad[PREFS_COPY].ng_LeftEdge = (PrefsNGad[PREFS_NEW].ng_LeftEdge +
- PrefsNGad[PREFS_DELETE].ng_LeftEdge) >> 1;
-
- /* Put the SAVE USE CANCEL Gadgets at the Bottom */
- PrefsNGad[PREFS_USE].ng_TopEdge =
- PrefsNGad[PREFS_SAVE].ng_TopEdge =
- PrefsNGad[PREFS_CANCEL].ng_TopEdge = Height - height - (FontY >> 1);
-
- PrefsNGad[PREFS_SAVE].ng_LeftEdge = PrefsLeft + FontX;
- PrefsNGad[PREFS_CANCEL].ng_LeftEdge = PrefsLeft + Width - len - FontX;
- PrefsNGad[PREFS_USE].ng_LeftEdge = (PrefsNGad[PREFS_SAVE].ng_LeftEdge +
- PrefsNGad[PREFS_CANCEL].ng_LeftEdge) >> 1;
-
- /* put Suffix, Command and Asynch Boxes under the title */
- PrefsNGad[PREFS_SUFFIX].ng_TopEdge = OffY + ComputeY(11) + 3.5*FontY;
- PrefsNGad[PREFS_COMMAND].ng_TopEdge = PrefsNGad[PREFS_SUFFIX].ng_TopEdge +
- height + (FontY << 1);
- PrefsNGad[PREFS_ASYNCH].ng_TopEdge = PrefsNGad[PREFS_COMMAND].ng_TopEdge +
- height + (FontY << 1);
-
- }
-
- void ComputeFont( UWORD *width, UWORD *height ) {
-
- Font.ta_Name = GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
- Font.ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
- FontX = GfxBase->DefaultFont->tf_XSize;
-
- OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
- OffX = Scr->WBorLeft;
-
- *width = 50 * FontX;
- *height = 18 * FontY;
-
- /* if the window is too big with the current font, use topaz 8 */
- if ( *width && *height ) {
- if (( ComputeX( *width ) + OffX + Scr->WBorRight ) > Scr->Width )
- goto UseTopaz;
- if (( ComputeY( *height ) + OffY + Scr->WBorBottom ) > Scr->Height )
- goto UseTopaz;
- }
- return;
-
- UseTopaz:
- Font.ta_Name = "topaz.font";
- FontX = FontY = Font.ta_YSize = 8;
- *width = 400;
- *height = 144;
-
- }
-
-
- void PrintTitle( void )
- {
- static char *PrefsIText[] = {
- "Show V1.0",
- "©1994 Jeff Shepherd",
- };
-
- struct IntuiText it = {
- 1, 0, JAM2, 120, 4, &Font, NULL, NULL
- };
-
- UWORD cnt;
- UWORD titlelen = (strlen(PrefsIText[1]) + 2) *FontX;
-
- ComputeFont( &PrefsWidth, &PrefsHeight );
-
- DrawBevelBox( PrefsWnd->RPort,
- OffX + ComputeX(34),
- OffY + ComputeY(11),
- titlelen,
- 2.5*FontY,
- GT_VisualInfo, VisualInfo,
- GTBB_Recessed, TRUE,
- TAG_DONE);
-
- for ( cnt = 0; cnt < Prefs_TNUM; cnt++ ) {
- it.IText = PrefsIText[cnt];
- it.LeftEdge = OffX + ComputeX(34+(titlelen >> 1) - (IntuiTextLength(&it) >> 1));
- it.TopEdge = OffY + ComputeY( 11 + (FontY >> 2) + cnt*FontY);
- PrintIText( PrefsWnd->RPort, &it, 0, 0 );
- }
- }
-
- #ifdef TEST
- struct List *MakeList(struct SuffixNode *SNode, int len) {
- struct List *retval = AllocMem(sizeof(struct List),MEMF_PUBLIC|MEMF_CLEAR);
- int i;
-
- if (retval) {
- NewList(retval);
-
- for (i=0; i < len; i++,SNode++) {
-
- struct SuffixList *NewNode = MakeNode(SNode->suffix,
- SNode->command, SNode->Asynch);
- if (NewNode)
- AddHead(retval,(struct Node *)NewNode);
- else break;
- } /* for */
- } /* if */
- return retval;
- }
- #endif
-
- void HandlePrefsIDCMP(void)
- {
- struct IntuiMessage *m;
- struct IntuiMessage PrefsMsg;
- struct MenuItem *n;
- LONG sig=0, sig2 =0;
- ULONG signals;
- LONG notifysig;
- LONG winsig = 1 << PrefsWnd->UserPort->mp_SigBit;
-
- int (*func)(struct IntuiMessage *,struct Gadget **);
- int (*menufunc)(struct Gadget **);
- BOOL running = TRUE;
-
- /* automatically adjusts font when prefs are changed */
- #ifdef __GNUC__
- struct NotifyRequest nr __attribute__((aligned(16)));
- struct NotifyRequest nr2 __attribute__((aligned(16)));
- #else
- _aligned struct NotifyRequest nr;
- _aligned struct NotifyRequest nr2;
- #endif
-
- if ( ((sig = AllocSignal(-1L)) != -1) && ((sig2 = AllocSignal(-1L)) != -1) ) {
- notifysig = (1L << sig) | (1L << sig2);
- nr.nr_stuff.nr_Signal.nr_SignalNum = sig;
- nr2.nr_stuff.nr_Signal.nr_SignalNum = sig2;
-
- nr.nr_Name = "env:sys/font.prefs";
- nr2.nr_Name = "env:sys/screenmode.prefs";
-
- nr.nr_Flags = nr2.nr_Flags = NRF_SEND_SIGNAL;
- nr.nr_stuff.nr_Signal.nr_Task =
- nr2.nr_stuff.nr_Signal.nr_Task = (struct Task *)FindTask(NULL);
-
- if ( ((StartNotify(&nr)) == DOSTRUE) && ((StartNotify(&nr2)) == DOSTRUE) ) {
-
- while (running) {
-
- signals =Wait(notifysig | winsig);
-
- if (signals & winsig) {
- while(m = GT_GetIMsg(PrefsWnd->UserPort)) {
-
- CopyMem(m , &PrefsMsg, sizeof(struct IntuiMessage));
- GT_ReplyIMsg(m);
-
- switch (PrefsMsg.Class) {
-
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh(PrefsWnd);
- PrintTitle();
- GT_EndRefresh(PrefsWnd, TRUE);
- break;
-
- case IDCMP_CLOSEWINDOW:
- running = FALSE;
- break;
-
- case IDCMP_GADGETUP:
- case IDCMP_GADGETDOWN:
- func = (void *) ((struct Gadget *)PrefsMsg.IAddress)->UserData;
- running = func(&PrefsMsg,PrefsGadgets);
- break;
-
- case IDCMP_MENUPICK:
- while(PrefsMsg.Code != MENUNULL && running) {
- n = ItemAddress(PrefsMenus, PrefsMsg.Code);
- menufunc = (void *)(GTMENUITEM_USERDATA(n));
- running = menufunc(PrefsGadgets);
- PrefsMsg.Code = n->NextSelect;
- }
- break;
-
- case IDCMP_VANILLAKEY:
- switch (PrefsMsg.Code) {
-
- case 'S':
- case 's':
- running = PREFS_SAVEClicked(&PrefsMsg,PrefsGadgets);
- break;
-
- case 'U':
- case 'u':
- running = PREFS_USEClicked(&PrefsMsg,PrefsGadgets);
- break;
-
- case 'C':
- case 'c':
- /* saves calling CANCELClicked */
- running = FALSE;
- break;
-
- case 'N':
- case 'n':
- running = PREFS_NEWClicked(&PrefsMsg,PrefsGadgets);
- break;
-
- case 'D':
- case 'd':
- running = PREFS_DELETEClicked(&PrefsMsg,PrefsGadgets);
- break;
-
- case 'F':
- case 'f':
- ActivateGadget(PrefsGadgets[PREFS_SUFFIX], PrefsWnd,NULL);
- break;
-
- case 'M':
- case 'm':
- ActivateGadget(PrefsGadgets[PREFS_COMMAND], PrefsWnd,NULL);
- break;
- } /* switch (PrefsMsg.Code) */
- } /* switch (PrefsMsg.Class) */
- } /* while (GetMsg) */
- } /* if (WinSig) */
- else {
- /* (signals & notifysig) == TRUE */
- GT_SetGadgetAttrs(PrefsGadgets[PREFS_SUFFIXES],PrefsWnd,NULL,
- (GTLV_Labels), ~0,
- (TAG_DONE) );
-
- DestroyWindow();
- Delay(150);
- CreateWindow();
- PrintTitle();
- GT_SetGadgetAttrs(PrefsGadgets[PREFS_SUFFIXES],PrefsWnd,NULL,
- (GTLV_Labels), Suffix_List,
- (TAG_DONE) );
-
- winsig = 1L << PrefsWnd->UserPort->mp_SigBit;
- } /* if */
- } /* while (running) */
- EndNotify(&nr2);
- EndNotify(&nr);
- } /* StartNotify */
- else {
- Error("Not enough memory for NotifyRequest.");
- }
- FreeSignal(sig);
- FreeSignal(sig2);
- } /* AllocSignal */
- else {
- Error("Could not allocate signal.");
- }
- }
-
- int main(int argc, char **argv) {
-
- FromWB = (argc == 0) ? TRUE : FALSE;
-
- if ( !(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37)))
- panic("Cannot open intuition library version 37",1);
-
- if ( !(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",37)))
- panic("Cannot open graphics library version 37",8);
-
- if ( !(GadToolsBase = OpenLibrary("gadtools.library",37)))
- panic("Cannot open gadtools library version 37",2);
-
- if ( !(AslBase = OpenLibrary("asl.library",37)))
- panic("Cannot open ASL library version 37",10);
-
- if ( !(IFFParseBase = OpenLibrary("iffparse.library",37)))
- panic("Cannot open iffparse library version 37",11);
-
-
- CreateWindow();
-
- #ifndef TEST
- if ( !(Suffix_List = AllocMem(sizeof(struct List),MEMF_PUBLIC|MEMF_CLEAR)))
- panic("Cannot allocate list",9);
- if ( !(Duplicate = AllocMem(sizeof(struct List),MEMF_PUBLIC|MEMF_CLEAR)))
- panic("Cannot allocate list",9);
-
- NewList(Suffix_List);
- NewList(Duplicate);
- LoadPrefs("env:show.prefs",PrefsGadgets,TRUE,Duplicate);
- #else
- if (! (Suffix_List=MakeList(test,4)))
- panic("Could not initialize listview list",9);
-
- GT_SetGadgetAttrs(PrefsGadgets[PREFS_SUFFIXES],PrefsWnd,NULL,
- (GTLV_Labels), Suffix_List,
- (TAG_DONE) );
- #endif
-
- PrintTitle();
- HandlePrefsIDCMP();
- panic(NULL,0);
- }
-
- /* clean up time */
- void panic(char *error, int retval) {
-
- /* print the error message if any */
- if (error) {
- if (FromWB)
- Error(error);
- else
- fprintf(stderr,"ERROR: %s\n",error);
- }
-
-
- /* destroy List */
- if (Duplicate) {
- Destroy_List(Duplicate);
- FreeMem(Duplicate, sizeof(struct List));
- }
-
- if (Suffix_List) {
- Destroy_List(Suffix_List);
- FreeMem(Suffix_List, sizeof(struct List));
- }
-
- DestroyWindow();
-
-
- if (IFFParseBase)
- CloseLibrary(IFFParseBase);
-
- if (AslBase)
- CloseLibrary(AslBase);
-
- if (GadToolsBase)
- CloseLibrary(GadToolsBase);
-
- if (GfxBase)
- CloseLibrary((struct Library *)GfxBase);
-
- if (IntuitionBase)
- CloseLibrary((struct Library *)IntuitionBase);
-
- exit(retval);
- }
-
-
- /* stubs */
- #if 0
- void DrawBevelBox( struct RastPort *rport, long left, long top, long width,
- long height, Tag tag1, ... ) {
- DrawBevelBoxA(rport,left,top,width,height,(struct TagItem *)&tag1);
- }
- #endif
-
-
- void CreateWindow(void) {
-
- UWORD wleft = PrefsLeft, wtop = PrefsTop;
- UWORD ww, wh;
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc, tc;
-
- if ( !(Scr= LockPubScreen(NULL)) )
- panic("Could not lock public screen",3);
-
- if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
- panic("Cannot get visualinfo",4);
-
- ComputeFont( &PrefsWidth, &PrefsHeight );
- ComputeGadgets(PrefsWidth, PrefsHeight);
-
- ww = ComputeX( PrefsWidth );
- wh = ComputeY( PrefsHeight );
-
- if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
- if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
-
- if ( ! ( g = CreateContext( &PrefsGList )))
- panic("Cannot create context",5);
-
- /* make gadgets */
- for( lc = 0, tc = 0; lc < Prefs_CNT; lc++ ) {
- CopyMem(&PrefsNGad[lc],&ng,sizeof(struct NewGadget));
-
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = &Font;
- ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
- ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
- ng.ng_Width = ComputeX( ng.ng_Width );
- ng.ng_Height = ComputeY( ng.ng_Height);
-
- PrefsGadgets[lc] = g = CreateGadgetA(PrefsGTypes[lc], g, &ng, (struct TagItem *)&PrefsGTags[tc]);
-
- while(PrefsGTags[tc]) tc += 2;
- tc++;
-
- if (!g)
- panic("Cannot create gadgets",6);
- }
-
- if (!(PrefsMenus = CreateMenus(PrefsNewMenu,
- GTMN_NewLookMenus, TRUE,
- GTMN_FrontPen, 1,
- TAG_DONE)))
- panic("Cannot create menus",7);
-
- LayoutMenus(PrefsMenus, VisualInfo, TAG_DONE);
-
- if (!( PrefsWnd = OpenWindowTags( NULL,
- WA_Left, wleft,
- WA_Top, wtop,
- WA_Width, ww + OffX + Scr->WBorRight,
- WA_Height, wh + OffY + Scr->WBorBottom,
- WA_IDCMP, BUTTONIDCMP|LISTVIEWIDCMP|STRINGIDCMP|CHECKBOXIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Gadgets, PrefsGList,
- WA_Title, PrefsWdt,
- WA_NewLookMenus, TRUE,
- WA_Zoom, Zoom,
- WA_PubScreen, Scr,
- TAG_DONE )))
- panic("Cannot open window",7);
-
- SetMenuStrip( PrefsWnd, PrefsMenus );
- GT_RefreshWindow( PrefsWnd, NULL );
- }
-
- void DestroyWindow(void) {
- if (PrefsMenus) {
- ClearMenuStrip(PrefsWnd);
- FreeMenus(PrefsMenus);
- }
-
- if (PrefsWnd) {
- /* Reply to any Messages */
- struct Message *mess;
- while(mess = GetMsg(PrefsWnd->UserPort))
- ReplyMsg(mess);
- CloseWindow(PrefsWnd);
- }
-
- if (PrefsGList)
- FreeGadgets(PrefsGList);
-
- if (VisualInfo)
- FreeVisualInfo(VisualInfo);
-
- if (Scr)
- UnlockPubScreen(NULL,Scr);
- }
-
- @
-