home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The AGA Experience 2
/
agavol2.iso
/
software
/
utilities
/
emulation
/
frodo
/
src
/
frodogui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-14
|
11KB
|
372 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Christian Bauer
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include "FrodoGUI.h"
struct Screen *Scr = NULL;
UBYTE *PubScreenName = "Workbench";
APTR VisualInfo = NULL;
struct Window *PrefsWnd = NULL;
struct Gadget *PrefsGList = NULL;
struct Menu *PrefsMenus = NULL;
struct Gadget *PrefsGadgets[34];
extern Class *initGet( void );
struct IClass *getClass = NULL;
struct _Object *getImage = NULL;
UWORD PrefsLeft = 0;
UWORD PrefsTop = 11;
UWORD PrefsWidth = 632;
UWORD PrefsHeight = 209;
UBYTE *PrefsWdt = (UBYTE *)" ";
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
UBYTE *ScreenType0Labels[] = {
(UBYTE *)"8 Bit RTG",
(UBYTE *)"4 Bit c2p4",
(UBYTE *)"1 Bit Amiga",
NULL };
UBYTE *Drv8Type0Labels[] = {
(UBYTE *)"Dir",
(UBYTE *)"D64",
(UBYTE *)"IEC",
NULL };
UBYTE *Drv9Type0Labels[] = {
(UBYTE *)"Dir",
(UBYTE *)"D64",
(UBYTE *)"IEC",
NULL };
UBYTE *Drv11Type0Labels[] = {
(UBYTE *)"Dir",
(UBYTE *)"D64",
(UBYTE *)"IEC",
NULL };
UBYTE *Drv10Type0Labels[] = {
(UBYTE *)"Dir",
(UBYTE *)"D64",
(UBYTE *)"IEC",
NULL };
UBYTE *SIDType0Labels[] = {
(UBYTE *)"Keine",
(UBYTE *)"SID-Karte",
(UBYTE *)"6581sid.library",
(UBYTE *)"playsid.library",
NULL };
struct NewMenu PrefsNewMenu[] = {
NM_TITLE, (STRPTR)"Projekt", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Öffnen...", (STRPTR)"O", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Sichern", (STRPTR)"S", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Sichern als...", (STRPTR)"A", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Über Frodo...", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"OK", (STRPTR)"R", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Abbrechen", (STRPTR)"Q", 0, 0L, NULL,
NM_END, NULL, NULL, 0, 0L, NULL };
UWORD PrefsGTypes[] = {
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
BUTTON_KIND,
TEXT_KIND,
CYCLE_KIND,
GENERIC_KIND,
GENERIC_KIND,
GENERIC_KIND,
GENERIC_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
INTEGER_KIND,
INTEGER_KIND,
INTEGER_KIND,
INTEGER_KIND,
STRING_KIND,
STRING_KIND,
STRING_KIND,
STRING_KIND,
CYCLE_KIND,
CYCLE_KIND,
CYCLE_KIND,
CYCLE_KIND,
CYCLE_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND
};
struct NewGadget PrefsNGad[] = {
84, 187, 101, 16, (UBYTE *)"_O", NULL, GD_OK, PLACETEXT_IN, NULL, NULL,
443, 187, 101, 16, (UBYTE *)"_C", NULL, GD_Cancel, PLACETEXT_IN, NULL, NULL,
263, 187, 101, 16, (UBYTE *)"_S", NULL, GD_Save, PLACETEXT_IN, NULL, NULL,
188, 72, 26, 11, (UBYTE *)"Joystick an Port 1", NULL, GD_Joystick1On, PLACETEXT_LEFT, NULL, NULL,
188, 86, 26, 11, (UBYTE *)"Joystick an Port 2", NULL, GD_Joystick2On, PLACETEXT_LEFT, NULL, NULL,
188, 100, 26, 11, (UBYTE *)"Joysticks vertauschen", NULL, GD_JoystickSwap, PLACETEXT_LEFT, NULL, NULL,
425, 6, 193, 14, NULL, NULL, GD_GetDisplayID, 0, NULL, NULL,
425, 20, 193, 14, (UBYTE *)"Bildschirmmodus", NULL, GD_DisplayID, PLACETEXT_LEFT, NULL, NULL,
425, 36, 143, 14, (UBYTE *)"Bildschirmtyp", NULL, GD_ScreenType, PLACETEXT_LEFT, NULL, NULL,
598, 85, 20, 14, NULL, NULL, GD_GetDir8, 0, NULL, NULL,
598, 101, 20, 14, NULL, NULL, GD_GetDir9, 0, NULL, NULL,
598, 117, 20, 14, NULL, NULL, GD_GetDir10, 0, NULL, NULL,
598, 133, 20, 14, NULL, NULL, GD_GetDir11, 0, NULL, NULL,
592, 151, 26, 11, (UBYTE *)"IEC für andere Geräte verwenden", NULL, GD_OtherIEC, PLACETEXT_LEFT, NULL, NULL,
188, 114, 26, 11, (UBYTE *)"Amerik. Tastatur", NULL, GD_KeyboardYZ, PLACETEXT_LEFT, NULL, NULL,
188, 142, 26, 11, (UBYTE *)"Sprite-Kollisionen", NULL, GD_Collisions, PLACETEXT_LEFT, NULL, NULL,
592, 164, 26, 11, (UBYTE *)"'/' -> '\' in Dateinamen", NULL, GD_MapSlash, PLACETEXT_LEFT, NULL, NULL,
188, 156, 26, 11, (UBYTE *)"Schneller Reset", NULL, GD_FastReset, PLACETEXT_LEFT, NULL, NULL,
188, 170, 26, 11, (UBYTE *)"Geschw. begrenzen", NULL, GD_LimitSpeed, PLACETEXT_LEFT, NULL, NULL,
188, 6, 81, 14, (UBYTE *)"Zyklen/Zeile (CPU)", NULL, GD_NormalCycles, PLACETEXT_LEFT, NULL, NULL,
188, 22, 81, 14, (UBYTE *)"Zyklen/Bad Line (CPU)", NULL, GD_BadLineCycles, PLACETEXT_LEFT, NULL, NULL,
188, 38, 81, 14, (UBYTE *)"Zyklen/Zeile (CIA)", NULL, GD_CIACycles, PLACETEXT_LEFT, NULL, NULL,
188, 54, 81, 14, (UBYTE *)"Jedes (n)te Bild", NULL, GD_SkipLatch, PLACETEXT_LEFT, NULL, NULL,
405, 85, 193, 14, NULL, NULL, GD_Dir8, 0, NULL, NULL,
405, 101, 193, 14, NULL, NULL, GD_Dir9, 0, NULL, NULL,
405, 117, 193, 14, NULL, NULL, GD_Dir10, 0, NULL, NULL,
405, 133, 193, 14, NULL, NULL, GD_Dir11, 0, NULL, NULL,
340, 85, 65, 14, (UBYTE *)"Laufwerk 8", NULL, GD_Drv8Type, PLACETEXT_LEFT, NULL, NULL,
340, 101, 65, 14, (UBYTE *)"Laufwerk 9", NULL, GD_Drv9Type, PLACETEXT_LEFT, NULL, NULL,
340, 133, 65, 14, (UBYTE *)"Laufwerk 11", NULL, GD_Drv11Type, PLACETEXT_LEFT, NULL, NULL,
340, 117, 65, 14, (UBYTE *)"Laufwerk 10", NULL, GD_Drv10Type, PLACETEXT_LEFT, NULL, NULL,
425, 67, 193, 14, (UBYTE *)"SID-Emulation", NULL, GD_SIDType, PLACETEXT_LEFT, NULL, NULL,
592, 52, 26, 11, (UBYTE *)"Direkter Videozugriff erlaubt", NULL, GD_DirectVideo, PLACETEXT_LEFT, NULL, NULL,
188, 128, 26, 11, (UBYTE *)"Sprite-Darstellung", NULL, GD_SpritesOn, PLACETEXT_LEFT, NULL, NULL
};
ULONG PrefsGTags[] = {
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GTTX_Border), TRUE, (TAG_DONE),
(GTCY_Labels), (ULONG)&ScreenType0Labels[ 0 ], (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GTIN_Number), 0, (GTIN_MaxChars), 10, (TAG_DONE),
(GTIN_Number), 0, (GTIN_MaxChars), 10, (TAG_DONE),
(GTIN_Number), 0, (GTIN_MaxChars), 10, (TAG_DONE),
(GTIN_Number), 0, (GTIN_MaxChars), 10, (TAG_DONE),
(GTST_MaxChars), 256, (TAG_DONE),
(GTST_MaxChars), 256, (TAG_DONE),
(GTST_MaxChars), 256, (TAG_DONE),
(GTST_MaxChars), 256, (TAG_DONE),
(GTCY_Labels), (ULONG)&Drv8Type0Labels[ 0 ], (TAG_DONE),
(GTCY_Labels), (ULONG)&Drv9Type0Labels[ 0 ], (TAG_DONE),
(GTCY_Labels), (ULONG)&Drv11Type0Labels[ 0 ], (TAG_DONE),
(GTCY_Labels), (ULONG)&Drv10Type0Labels[ 0 ], (TAG_DONE),
(GTCY_Labels), (ULONG)&SIDType0Labels[ 0 ], (TAG_DONE),
(TAG_DONE),
(TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
FontX = Scr->RastPort.Font->tf_XSize;
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
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 = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
if ( ! ( getClass = initGet()))
return( 3L );
if ( ! ( getImage = NewObject( getClass, NULL, GT_VisualInfo, VisualInfo, TAG_DONE )))
return( 4L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( getImage ) {
DisposeObject( getImage );
getImage = NULL;
}
if ( getClass ) {
FreeClass( getClass );
getClass = NULL;
}
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
int OpenPrefsWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = PrefsLeft, wtop = PrefsTop, ww, wh;
ComputeFont( 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 )))
return( 1L );
for( lc = 0, tc = 0; lc < Prefs_CNT; lc++ ) {
CopyMem((char * )&PrefsNGad[ lc ], (char * )&ng, (long)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 );
if ( PrefsGTypes[ lc ] != GENERIC_KIND ) {
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
}
PrefsGadgets[ lc ] = g = CreateGadgetA((ULONG)PrefsGTypes[ lc ], g, &ng, ( struct TagItem * )&PrefsGTags[ tc ] );
if ( PrefsGTypes[ lc ] == GENERIC_KIND ) {
g->Flags |= GFLG_GADGIMAGE | GFLG_GADGHIMAGE;
g->Activation |= GACT_RELVERIFY;
g->GadgetRender = (APTR)getImage;
g->SelectRender = (APTR)getImage;
}
while( PrefsGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( PrefsMenus = CreateMenus( PrefsNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
return( 3L );
LayoutMenus( PrefsMenus, VisualInfo, GTMN_NewLookMenus, TRUE, 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|CHECKBOXIDCMP|TEXTIDCMP|CYCLEIDCMP|IDCMP_GADGETUP|INTEGERIDCMP|STRINGIDCMP|IDCMP_MENUPICK|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH|WFLG_SIMPLE_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, PrefsGList,
WA_Title, PrefsWdt,
WA_ScreenTitle, " ",
WA_AutoAdjust, TRUE,
WA_NewLookMenus, TRUE,
TAG_DONE )))
return( 4L );
SetMenuStrip( PrefsWnd, PrefsMenus );
GT_RefreshWindow( PrefsWnd, NULL );
return( 0L );
}
void ClosePrefsWindow( void )
{
if ( PrefsMenus ) {
ClearMenuStrip( PrefsWnd );
FreeMenus( PrefsMenus );
PrefsMenus = NULL; }
if ( PrefsWnd ) {
CloseWindow( PrefsWnd );
PrefsWnd = NULL;
}
if ( PrefsGList ) {
FreeGadgets( PrefsGList );
PrefsGList = NULL;
}
}