home *** CD-ROM | disk | FTP | other *** search
- /*
- * Source machine generated by GadToolsBox V2.0
- * which is (c) Copyright 1991-1993 Jaba Development
- *
- * GUI Designed by : Chris Conger
- */
-
- #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 "plotgui.h"
- #include "cp.h"
-
- extern UBYTE *version_string;
-
- struct Screen *Scr = NULL;
- APTR VisualInfo = NULL;
- struct Window *PlotWindowWnd = NULL;
- struct Window *delwinWnd = NULL;
- struct Gadget *PlotWindowGList = NULL;
- struct Gadget *delwinGList = NULL;
- struct Menu *PlotWindowMenus = NULL;
- struct IntuiMessage PlotWindowMsg;
- struct IntuiMessage delwinMsg;
- struct Gadget *PlotWindowGadgets[6];
- struct Gadget *delwinGadgets[3];
- UWORD SWIDTH = STDSCREENWIDTH;
- UWORD SHEIGHT = STDSCREENHEIGHT;
- UWORD delwinLeft = 80;
- UWORD delwinTop = 40;
- UWORD delwinWidth = 200;
- UWORD delwinHeight = 140;
- UBYTE *PlotWindowWdt = (UBYTE *)"PWin";
- UBYTE *delwinWdt = (UBYTE *)"Delete Trace";
-
- WORD GADHEIGHT;
- WORD GADWIDTH;
-
- /*struct TextAttr cPFont = {
- ( STRPTR )"topaz.font", 8, 0x00, 0x00 };
- */
-
- struct NewMenu PlotWindowNewMenu[] = {
- NM_TITLE, (STRPTR)"Project", NULL, 0, NULL, NULL,
- NM_ITEM, (STRPTR)"Open File", (STRPTR)"O", 0, 0L, (APTR)newfile,
- NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
- NM_ITEM, (STRPTR)"Add File", (STRPTR)"A", 0, 0L, (APTR)addClicked,
- NM_ITEM, (STRPTR)"Delete Set", (STRPTR)"D", 0, 0L, (APTR)deleteClicked,
- NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
- NM_ITEM, (STRPTR)"About", NULL, 0, 0L, (APTR)PlotWindowItem0,
- NM_ITEM, (STRPTR)"Die", (STRPTR)"Q", 0, 0L, (APTR)PlotWindowItem1,
- NM_TITLE, (STRPTR)"Axis", NULL, 0, NULL, NULL,
- NM_ITEM, (STRPTR)"XAxis", NULL, 0, NULL, NULL,
- NM_SUB, (STRPTR)"Lin", NULL, 0, 0L, (APTR)PlotWindowItem2,
- NM_SUB, (STRPTR)"Log", NULL, 0, 0L, (APTR)PlotWindowItem3,
- NM_ITEM, (STRPTR)"YAxis", NULL, 0, NULL, NULL,
- NM_SUB, (STRPTR)"Lin", NULL, 0, 0L, (APTR)PlotWindowItem4,
- NM_SUB, (STRPTR)"Log", NULL, 0, 0L, (APTR)PlotWindowItem5,
- NM_TITLE, (STRPTR)"Display", NULL, 0, NULL, NULL,
- NM_ITEM, (STRPTR)"Full View", (STRPTR)"F", 0L, 0L, (APTR)fullClicked,
- NM_ITEM, (STRPTR)"Grid", (STRPTR)"G", 0L, 0L, (APTR)gridClicked,
- NM_ITEM, (STRPTR)"Symbols", (STRPTR)"Y", 0L, 0L, (APTR)PlotWindowItem6,
- NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
- NM_ITEM, (STRPTR)"Control Panel", (STRPTR)"C", 0L, 0L, (APTR)PlotWindowItem7,
- NM_END, NULL, NULL, 0, 0L, NULL };
-
-
- UWORD PlotWindowGTypes[] = {
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND
- };
-
- UWORD delwinGTypes[] = {
- LISTVIEW_KIND,
- BUTTON_KIND,
- BUTTON_KIND
- };
-
- struct NewGadget PlotWindowNGad[] = {
- NULL, NULL, NULL, NULL, (UBYTE *)"_Add", NULL, GD_add, PLACETEXT_IN, NULL, (APTR)addClicked,
- NULL, NULL, NULL, NULL, (UBYTE *)"_Kill", NULL, GD_delete, PLACETEXT_IN, NULL, (APTR)deleteClicked,
- NULL, NULL, NULL, NULL, (UBYTE *)"_Full", NULL, GD_full, PLACETEXT_IN, NULL, (APTR)fullClicked,
- NULL, NULL, NULL, NULL, (UBYTE *)"_Zoom", NULL, GD_zoom, PLACETEXT_IN, NULL, (APTR)zoomClicked,
- NULL, NULL, NULL, NULL, (UBYTE *)"_Grid", NULL, GD_grid, PLACETEXT_IN, NULL, (APTR)gridClicked,
- NULL, NULL, NULL, NULL, (UBYTE *)"_Quit", NULL, GD_quit, PLACETEXT_IN, NULL, (APTR)quitClicked
- };
-
- struct NewGadget delwinNGad[] = {
- 20, 20, 150, 75, NULL, NULL, GD_dellist, NULL, NULL, (APTR)dellistClicked,
- 25, 100, 65, 25, (UBYTE *)"_Delete", NULL, GD_delset, PLACETEXT_IN, NULL, (APTR)delsetClicked,
- 100, 100, 65, 25, (UBYTE *)"_Redraw", NULL, GD_canlist, PLACETEXT_IN, NULL, (APTR)canlistClicked
- };
-
- ULONG PlotWindowGTags[] = {
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE)
- };
-
- ULONG delwinGTags[] = {
- (GTLV_ShowSelected), NULL, (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE)
- };
-
-
- struct ColorSpec MonoColors[] = {
- 0, 0x00, 0x00, 0x00,
- 1, 0x0F, 0x0E, 0x0D,
- ~0, 0x00, 0x00, 0x00 };
-
- struct ColorSpec FourColors[] = {
- 0, 0x07, 0x06, 0x06,
- 1, 0x0B, 0x0A, 0x0A,
- 2, 0x03, 0x01, 0x03,
- 3, 0x0F, 0x00, 0x05,
- ~0, 0x00, 0x00, 0x00 };
-
- struct ColorSpec EightColors[] = {
- 0, 0x08, 0x06, 0x06,
- 1, 0x00, 0x00, 0x00,
- 2, 0x0C, 0x0C, 0x0F,
- 3, 0x09, 0x07, 0x08,
- 4, 0x0A, 0x09, 0x0F,
- 5, 0x0F, 0x0E, 0x08,
- 6, 0x05, 0x04, 0x05,
- 7, 0x0F, 0x0F, 0x0F,
- ~0, 0x00, 0x00, 0x00 };
-
- struct ColorSpec SixteenColors[] = {
- 0, 0x08, 0x06, 0x06,
- 1, 0x00, 0x00, 0x00,
- 2, 0x0C, 0x0C, 0x0F,
- 3, 0x09, 0x07, 0x08,
- 4, 0x0A, 0x09, 0x0F,
- 5, 0x0F, 0x0E, 0x08,
- 6, 0x0F, 0x05, 0x06,
- 7, 0x00, 0x0F, 0x09,
- 8, 0x0D, 0x07, 0x0D,
- 9, 0x03, 0x06, 0x0C,
- 10, 0x0F, 0x09, 0x08,
- 11, 0x0B, 0x02, 0x0F,
- 12, 0x01, 0x0F, 0x0D,
- 13, 0x0F, 0x00, 0x08,
- 14, 0x05, 0x04, 0x05,
- 15, 0x0F, 0x0F, 0x0F,
- ~0, 0x00, 0x00, 0x00 };
-
- UWORD DriPens[] = {
- 0,1,2,2,1,3,2,0,2,~0 };
-
- UWORD TwoPens[] = {
- 0,1,2,1,2,3,2,0,2,~0 };
-
-
- int SetupScreen( void )
- {
- UBYTE PubNum[4];
- struct List *publist;
- struct PubScreenNode *psnode;
- WORD s=0,t;
- WORD len;
- struct ColorSpec *ScreenColors;
- UBYTE PubName[8];
-
- strcpy(PubName,"cP");
- len = (WORD) strlen( PubName );
-
- publist = LockPubScreenList(); /* Lock the public screen list */
-
- for (psnode = (struct PubScreenNode *) publist->lh_Head; psnode->psn_Node.ln_Succ; psnode = (struct PubScreenNode *) psnode->psn_Node.ln_Succ)
- {
- if ( ! Strnicmp( psnode-> psn_Node.ln_Name, PubName, len))
- {
- t = 0;
- sscanf( &psnode-> psn_Node.ln_Name [len],"%hd", &t);
- s = max(s,t);
- }
- }
-
- UnlockPubScreenList ();
-
- sprintf( PubNum,"%hd", s+1 );
- strcpy ( PubName,"cP");
- strcat ( PubName, PubNum); /* Add #s of other cP screens to name */
-
- if ( depth == 1 ) ScreenColors = &MonoColors[0];
- if ( depth == 2 ) ScreenColors = &FourColors[0];
- if ( depth == 3 ) ScreenColors = &EightColors[0];
- if ( depth == 4 ) ScreenColors = &SixteenColors[0];
-
- if ( depth == 1 )
- {
- DriPens[0] = ~0;
- }
-
- if ( ! ( Scr = OpenScreenTags( NULL, SA_Left, 0,
- SA_Top, 0,
- SA_Width, SWIDTH,
- SA_Height, SHEIGHT,
- SA_Depth, depth,
- SA_Colors, ScreenColors,
- SA_Font, cPFont,
- SA_Type, PUBLICSCREEN,
- SA_PubName, PubName,
- SA_DisplayID, DEFAULT_MONITOR_ID | Disp,
- SA_Overscan, OSCAN_TEXT,
- SA_AutoScroll, TRUE,
- SA_Pens, (depth == 2 ? &TwoPens[0] : &DriPens[0]),
- SA_Title, &version_string[5],
- TAG_DONE )))
- return( 1L );
-
- if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
- return( 2L );
-
- PubScreenStatus( Scr, NULL ); /* make screen public */
- if ( DEFS ) SetDefaultPubScreen( PubName ); /* make screen default pub if DEFS True */
-
- return( 0L );
- }
-
- void CloseDownScreen( void )
- {
- struct EasyStruct myezreq = {
- sizeof (struct EasyStruct), 0,
- "Close Public Screen",
- "Please Close All Windows on this Screen",
- "OK"
- };
-
- if ( VisualInfo ) {
- FreeVisualInfo( VisualInfo );
- VisualInfo = NULL;
- }
- if ( Scr ) {
-
- PubScreenStatus( Scr, PSNF_PRIVATE ); /* make the screen unavailable */
-
- while( ! CloseScreen( Scr ))
- {
- Forbid();
- EasyRequestArgs( Scr-> FirstWindow, &myezreq, NULL, NULL );
- Permit();
- }
-
- }
- Scr = NULL;
- }
-
- int HandlePlotWindowIDCMP( void )
- {
- struct IntuiMessage *m;
- struct MenuItem *n;
- int (*func)();
- BOOL running = TRUE;
-
- while( m = GT_GetIMsg( PlotWindowWnd->UserPort )) {
-
- CopyMem(( char * )m, ( char * )&PlotWindowMsg, (long)sizeof( struct IntuiMessage ));
-
- GT_ReplyIMsg( m );
-
- switch ( PlotWindowMsg.Class ) {
-
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh( PlotWindowWnd );
- GT_EndRefresh( PlotWindowWnd, TRUE );
- break;
-
- case IDCMP_VANILLAKEY:
- running = PlotWindowVanillaKey();
- break;
-
- case IDCMP_MOUSEBUTTONS:
- if (PlotWindowMsg.Code == SELECTDOWN)
- Identify(PlotWindowMsg.MouseX, PlotWindowMsg.MouseY, TRUE);
- else if (PlotWindowMsg.Code == SELECTUP)
- Identify(PlotWindowMsg.MouseX, PlotWindowMsg.MouseY, FALSE);
- break;
-
- case IDCMP_GADGETUP:
- func = ( void * )(( struct Gadget * )PlotWindowMsg.IAddress )->UserData;
- running = func();
- break;
-
- case IDCMP_MENUPICK:
- while( PlotWindowMsg.Code != MENUNULL ) {
- n = ItemAddress( PlotWindowMenus, PlotWindowMsg.Code );
- func = (void *)(GTMENUITEM_USERDATA( n ));
- running = func();
- PlotWindowMsg.Code = n->NextSelect;
- }
- break;
- }
- }
- return( running );
- }
-
- int OpenPlotWindowWindow( void )
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc, tc;
- WORD GadTop;
-
- if ( ! ( g = CreateContext( &PlotWindowGList )))
- return( 1L );
-
- GADWIDTH = ( Scr-> Width - 2 * cPFont->ta_YSize ) / PlotWindow_CNT;
- GADHEIGHT = cPFont->ta_YSize * 2;
-
- GadTop = Scr-> Height - Scr-> BarHeight - cPFont->ta_YSize * 3;
-
- for( lc = 0, tc = 0; lc < PlotWindow_CNT; lc++ ) {
-
- PlotWindowNGad[ lc ] . ng_LeftEdge = GADWIDTH * lc + cPFont->ta_YSize;
- PlotWindowNGad[ lc ] . ng_Width = GADWIDTH;
- PlotWindowNGad[ lc ] . ng_TopEdge = GadTop;
- PlotWindowNGad[ lc ] . ng_Height = GADHEIGHT;
-
- CopyMem((char * )&PlotWindowNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
-
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = cPFont;
-
- PlotWindowGadgets[ lc ] = g = CreateGadgetA((ULONG)PlotWindowGTypes[ lc ], g, &ng, ( struct TagItem * )&PlotWindowGTags[ tc ] );
-
- while( PlotWindowGTags[ tc ] ) tc += 2;
- tc++;
-
- if ( NOT g )
- return( 2L );
- }
-
- if ( ! ( PlotWindowMenus = CreateMenus( PlotWindowNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
- return( 3L );
-
- LayoutMenus( PlotWindowMenus, VisualInfo, GTMN_TextAttr, cPFont, TAG_DONE );
-
- if ( ! ( PlotWindowWnd = OpenWindowTags( NULL,
- WA_Left, 0,
- WA_Top, Scr-> BarHeight,
- WA_Width, Scr-> Width,
- WA_Height, Scr-> Height - Scr-> BarHeight,
- WA_IDCMP, BUTTONIDCMP|IDCMP_MOUSEMOVE|IDCMP_MOUSEBUTTONS|IDCMP_MENUPICK|IDCMP_VANILLAKEY,
- WA_Flags, WFLG_SMART_REFRESH|WFLG_BACKDROP|WFLG_BORDERLESS|WFLG_ACTIVATE,
- WA_Gadgets, ( CPANEL ? PlotWindowGList : NULL),
- WA_ScreenTitle, &version_string[5],
- WA_AutoAdjust, TRUE,
- WA_PubScreen, Scr,
- TAG_DONE )))
- return( 4L );
-
- SetMenuStrip( PlotWindowWnd, PlotWindowMenus );
- GT_RefreshWindow( PlotWindowWnd, NULL );
-
- return( 0L );
- }
-
- void ClosePlotWindowWindow( void )
- {
- if ( PlotWindowMenus ) {
- ClearMenuStrip( PlotWindowWnd );
- FreeMenus( PlotWindowMenus );
- PlotWindowMenus = NULL; }
-
- if ( PlotWindowWnd ) {
- CloseWindow( PlotWindowWnd );
- PlotWindowWnd = NULL;
- }
-
- if ( PlotWindowGList ) {
- FreeGadgets( PlotWindowGList );
- PlotWindowGList = NULL;
- }
- }
-
- void delwinRender( void )
- {
- UWORD offx, offy;
-
- offx = delwinWnd->BorderLeft;
- offy = delwinWnd->BorderTop;
-
-
- DrawBevelBox( delwinWnd->RPort, offx + 10, offy + 10, 170, 120 , GT_VisualInfo, VisualInfo, GTBB_Recessed, TRUE, TAG_DONE );
- }
-
- int HandledelwinIDCMP( void )
- {
- struct IntuiMessage *m;
- int (*func)();
- BOOL running = TRUE;
-
- while( m = GT_GetIMsg( delwinWnd->UserPort )) {
-
- CopyMem(( char * )m, ( char * )&delwinMsg, (long)sizeof( struct IntuiMessage ));
-
- GT_ReplyIMsg( m );
-
- switch ( delwinMsg.Class ) {
-
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh( delwinWnd );
- delwinRender();
- GT_EndRefresh( delwinWnd, TRUE );
- break;
-
- case IDCMP_CLOSEWINDOW:
- running = delwinCloseWindow();
- break;
-
- case IDCMP_VANILLAKEY:
- running = delwinVanillaKey();
- break;
-
- case IDCMP_GADGETUP:
- case IDCMP_GADGETDOWN:
- func = ( void * )(( struct Gadget * )delwinMsg.IAddress )->UserData;
- running = func();
- break;
- }
- }
- return( running );
- }
-
- int OpendelwinWindow( void )
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc, tc;
- UWORD offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
-
- if ( ! ( g = CreateContext( &delwinGList )))
- return( 1L );
-
- for( lc = 0, tc = 0; lc < delwin_CNT; lc++ ) {
-
- CopyMem((char * )&delwinNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
-
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = cPFont;
- ng.ng_LeftEdge += offx;
- ng.ng_TopEdge += offy;
-
- delwinGadgets[ lc ] = g = CreateGadgetA((ULONG)delwinGTypes[ lc ], g, &ng, ( struct TagItem * )&delwinGTags[ tc ] );
-
- while( delwinGTags[ tc ] ) tc += 2;
- tc++;
-
- if ( NOT g )
- return( 2L );
- }
-
- if ( ! ( delwinWnd = OpenWindowTags( NULL,
- WA_Left, delwinLeft,
- WA_Top, delwinTop,
- WA_Width, delwinWidth,
- WA_Height, delwinHeight + offy,
- WA_IDCMP, LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Gadgets, delwinGList,
- WA_Title, delwinWdt,
- WA_ScreenTitle, "Kill",
- WA_PubScreen, Scr,
- TAG_DONE )))
- return( 4L );
-
- GT_RefreshWindow( delwinWnd, NULL );
-
- delwinRender();
-
- return( 0L );
- }
-
- void ClosedelwinWindow( void )
- {
- if ( delwinWnd ) {
- CloseWindow( delwinWnd );
- delwinWnd = NULL;
- }
-
- if ( delwinGList ) {
- FreeGadgets( delwinGList );
- delwinGList = NULL;
- }
- }
-
-