home *** CD-ROM | disk | FTP | other *** search
- #include <intuition/intuition.h>
- #include <intuition/gadgetclass.h>
- #include <libraries/gadtools.h>
- #include <graphics/displayinfo.h>
- #include <graphics/gfxbase.h>
- #include <clib/gadtools_protos.h>
- #include <string.h>
- #include "mcdplayer.h"
-
- #define GD_ListInt 0
- #define GD_ListTitel 1
- #define GD_ListAktTitel 2
- #define GD_ListTitelliste 3
- #define GD_ListSave 4
- #define GD_ListAbbruch 5
- #define GD_ListBenutzen 6
-
- extern struct MsgPort *TimerMP;
-
- struct Window *ListWnd = NULL;
- struct Gadget *ListGList = NULL;
- struct Gadget *ListGadgets[7];
- WORD ListLeft;
- WORD ListTop;
- UWORD ListWidth = 348;
- UWORD ListHeight = 174;
- UBYTE *ListWdt = (UBYTE *)"Title List";
-
- struct List TitList;
- struct Node TitNode[100];
- char *Titles;
-
- void InitTitleList( void )
- {
- int i;
-
- if (Titles = AllocMem( 10000, MEMF_ANY|MEMF_CLEAR ))
- {
- NewList( &TitList );
- for( i=0; i<TOC_NumTracks; i++ )
- {
- TitNode[i].ln_Name = &(Titles[i*100]);
- strcpy( &(Titles[i*100]), TOC_Title[i] );
- AddTail( &TitList, &TitNode[i] );
- };
- }
- }
-
- void ExitTitleList( int Action ) /* 0=Exit, 1=Use, 2=Save */
- {
- struct StringInfo *sti;
- char *a;
- char Buffer[256];
- int i;
- BPTR FH;
-
- if (Action!=0)
- {
- a = TOC_TitleStrs;
-
- sti = ListGadgets[GD_ListInt]->SpecialInfo;
- strcpy( a, sti->Buffer );
- TOC_CDInterpret = a;
- a += strlen( a )+1;
-
- sti = ListGadgets[GD_ListTitel]->SpecialInfo;
- strcpy( a, sti->Buffer );
- TOC_CDTitle = a;
- a += strlen( a )+1;
-
- for( i=0; i<TOC_NumTracks; i++ )
- {
- strcpy( a, &Titles[i*100] );
- TOC_Title[i] = a;
- a += strlen( a )+1;
- }
- };
-
- if (Action==2)
- {
- sprintf( Buffer, SongPath );
- AddPart( Buffer, TOC_CDID, 130 );
-
- if (FH = Open( Buffer, MODE_NEWFILE ))
- {
- FPuts( FH, TOC_CDInterpret );
- FPutC( FH, '\n' );
- FPuts( FH, TOC_CDTitle );
- FPutC( FH, '\n' );
- for( i=0; i<TOC_NumTracks; i++ )
- {
- FPuts( FH, TOC_Title[i] );
- FPutC( FH, '\n' );
- };
- Close( FH );
- SetComment(Buffer,TOC_CDTitle);
- };
- };
-
- if (Titles) FreeMem( Titles, 10000 );
- }
-
- int OpenListWindow( void )
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD offx, offy;
-
- if ( ! ( Scr = LockPubScreen( 0 )))
- return( 1L );
-
- PlaceWnd( Scr, ListWidth, ListHeight + offy, &ListLeft, &ListTop, 0 );
-
- if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
- return( 2L );
-
- offx = Scr->WBorLeft;
- offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
-
- if ( ! ( g = CreateContext( &ListGList )))
- return( 1L );
-
- ng.ng_LeftEdge = offx + 84;
- ng.ng_TopEdge = offy + 2;
- ng.ng_Width = 250;
- ng.ng_Height = 14;
- ng.ng_GadgetText = (UBYTE *)"Identity";
- ng.ng_TextAttr = &topaz8;
- ng.ng_GadgetID = GD_ListInt;
- ng.ng_Flags = PLACETEXT_LEFT;
- ng.ng_VisualInfo = VisualInfo;
-
- g = CreateGadget( STRING_KIND, g, &ng, GTST_MaxChars, 100, GTST_String, TOC_CDInterpret, TAG_DONE );
-
- ListGadgets[ 0 ] = g;
-
- ng.ng_TopEdge = offy + 17;
- ng.ng_GadgetText = (UBYTE *)"CD Title ";
- ng.ng_GadgetID = GD_ListTitel;
-
- g = CreateGadget( STRING_KIND, g, &ng, GTST_MaxChars, 100, GTST_String, TOC_CDTitle, TAG_DONE );
-
- ListGadgets[ 1 ] = g;
-
- ng.ng_TopEdge = offy + 140;
- ng.ng_GadgetText = (UBYTE *)"Title";
- ng.ng_GadgetID = GD_ListAktTitel;
-
- g = CreateGadget( STRING_KIND, g, &ng, GTST_MaxChars, 100, TAG_DONE );
-
- ListGadgets[ 2 ] = g;
-
- ng.ng_TopEdge = offy + 32;
- ng.ng_Height = 120;
- ng.ng_GadgetText = NULL;
- ng.ng_GadgetID = GD_ListTitelliste;
- ng.ng_Flags = 0;
-
- g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, &TitList, GTLV_ShowSelected, ListGadgets[2], TAG_DONE );
-
- ListGadgets[ 3 ] = g;
-
- ng.ng_LeftEdge = offx + 5;
- ng.ng_TopEdge = offy + 153;
- ng.ng_Width = 80;
- ng.ng_Height = 14;
- ng.ng_GadgetText = (UBYTE *)"Save";
- ng.ng_GadgetID = GD_ListSave;
- ng.ng_Flags = PLACETEXT_IN;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- ListGadgets[ 4 ] = g;
-
- ng.ng_LeftEdge = offx + 254;
- ng.ng_GadgetText = (UBYTE *)"Cancel";
- ng.ng_GadgetID = GD_ListAbbruch;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- ListGadgets[ 5 ] = g;
-
- ng.ng_LeftEdge = offx + 128;
- ng.ng_GadgetText = (UBYTE *)"Use";
- ng.ng_GadgetID = GD_ListBenutzen;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- ListGadgets[ 6 ] = g;
-
- if ( ! g )
- return( 2L );
-
- if ( ! ( ListWnd = OpenWindowTags( NULL,
- WA_Left, ListLeft,
- WA_Top, ListTop,
- WA_Width, ListWidth,
- WA_Height, ListHeight + offy,
- WA_IDCMP, STRINGIDCMP|LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Gadgets, ListGList,
- WA_Title, ListWdt,
- WA_PubScreen, Scr,
- TAG_DONE )))
- return( 4L );
-
- GT_RefreshWindow( ListWnd, NULL );
- UnlockPubScreen( NULL, Scr );
- Scr = NULL;
-
- return( 0L );
- }
-
- void CloseListWindow( void )
- {
- if ( ListWnd )
- {
- CloseWindow( ListWnd );
- ListWnd = NULL;
- }
-
- if ( ListGList )
- {
- FreeGadgets( ListGList );
- ListGList = NULL;
- }
-
- if ( VisualInfo )
- {
- FreeVisualInfo( VisualInfo );
- VisualInfo = NULL;
- }
-
- if ( Scr )
- {
- UnlockPubScreen( NULL, Scr );
- }
- }
-
- void TitleList( void )
- {
- /* ULONG GClass;
- USHORT GCode;
- struct Gadget *GList = 0l;
- struct IntuiMessage *msg;
- struct StringInfo *sti;
- int Exit = 0;
- int AktTitel = -1;
- LONG Sig;
- */
- InitTitleList();
- if (OpenListWindow()) {CloseListWindow();ExitTitleList(0);}
- }
- void Handle_ListInput(void)
- {
- ULONG GClass;
- USHORT GCode;
- struct Gadget *GList = 0l;
- struct IntuiMessage *msg;
- struct StringInfo *sti;
- static int AktTitel = -1;
- while (msg = (struct IntuiMessage *) GT_GetIMsg( ListWnd->UserPort ) )
- {
- GClass = msg->Class;
- GCode = msg->Code;
- if (GClass & (GADGETDOWN | GADGETUP | MOUSEMOVE) )
- GList = (struct Gadget *) msg->IAddress;
- GT_ReplyIMsg(msg);
-
- switch (GClass)
- {
- case IDCMP_CLOSEWINDOW:
- ExitTitleList(0);
- CloseListWindow();
- return;
- case IDCMP_GADGETUP:
- switch (GList->GadgetID)
- {
- case GD_ListAktTitel:
- if (AktTitel!=-1)
- {
- sti = ListGadgets[GD_ListAktTitel]->SpecialInfo;
- strcpy( &Titles[AktTitel*100], sti->Buffer );
- if (AktTitel<TOC_NumTracks-1) AktTitel++;
- GT_SetGadgetAttrs(ListGadgets[GD_ListTitelliste], ListWnd, 0,GTLV_Labels, &TitList, GTLV_Selected, AktTitel, GTLV_MakeVisible, AktTitel-1, TAG_DONE);
- ActivateGadget(ListGadgets[GD_ListAktTitel], ListWnd, NULL );
- };
- break;
- case GD_ListTitelliste:
- AktTitel = GCode;
- ActivateGadget(ListGadgets[GD_ListAktTitel], ListWnd, NULL );
- break;
- case GD_ListInt:
- ActivateGadget(ListGadgets[GD_ListTitel], ListWnd, NULL );
- break;
- case GD_ListTitel:
- ActivateGadget(ListGadgets[GD_ListInt], ListWnd, NULL );
- break;
- case GD_ListSave:
- ExitTitleList(2);
- CloseListWindow();
- return;
- case GD_ListAbbruch:
- ExitTitleList(0);
- CloseListWindow();
- return;
- case GD_ListBenutzen:
- ExitTitleList(1);
- CloseListWindow();
- return;
- };
- break;
- };
- };
- }
-
-