home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / misc / cp-4.3.lha / cP / Source / plotgui.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-03  |  20.8 KB  |  675 lines

  1. /*
  2.  *  Source machine generated by GadToolsBox V2.0
  3.  *  which is (c) Copyright 1991-1993 Jaba Development
  4.  *
  5.  *  GUI Designed by : Chris Conger
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/classes.h>
  11. #include <intuition/classusr.h>
  12. #include <intuition/imageclass.h>
  13. #include <intuition/gadgetclass.h>
  14. #include <libraries/gadtools.h>
  15. #include <graphics/displayinfo.h>
  16. #include <graphics/gfxbase.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/intuition_protos.h>
  19. #include <clib/gadtools_protos.h>
  20. #include <clib/graphics_protos.h>
  21. #include <clib/utility_protos.h>
  22. #include <string.h>
  23. #include <clib/diskfont_protos.h>
  24.  
  25. #include "plotgui.h"
  26. #include "cp.h"
  27.  
  28. extern UBYTE *version_string;
  29.  
  30.  
  31. struct Screen         *Scr = NULL;
  32. APTR                   VisualInfo = NULL;
  33. struct Window         *PlotWindowWnd = NULL;
  34. struct Window         *delwinWnd = NULL;
  35. struct Gadget         *PlotWindowGList = NULL;
  36. struct Gadget         *delwinGList = NULL;
  37. struct Menu           *PlotWindowMenus = NULL;
  38. struct IntuiMessage    PlotWindowMsg;
  39. struct IntuiMessage    delwinMsg;
  40. struct Gadget         *PlotWindowGadgets[6];
  41. struct Gadget         *delwinGadgets[3];
  42. UWORD                  SWIDTH = STDSCREENWIDTH;
  43. UWORD                  SHEIGHT = STDSCREENHEIGHT;
  44. UWORD                  delwinWidth;
  45. UWORD                  delwinHeight;
  46. UBYTE                 *PlotWindowWdt = (UBYTE *)"ChrisP";
  47. UBYTE                 *delwinWdt = (UBYTE *)"Kill Trace";
  48. struct Window         *PreSlideWnd = NULL;
  49. struct Gadget         *PreSlideGList = NULL;
  50. struct IntuiMessage    PreSlideMsg;
  51. struct Gadget         *PreSlideGadgets[1];
  52. UBYTE                 *PreSlideWdt = (UBYTE *)"Precision for Identify Feature";
  53.  
  54. WORD GADHEIGHT;
  55. WORD GADWIDTH;
  56.  
  57.  
  58. struct NewMenu PlotWindowNewMenu[] = {
  59.      NM_TITLE, (STRPTR)"Project", NULL, 0, NULL, NULL,
  60.      NM_ITEM, (STRPTR)"Open File", (STRPTR)"O", 0, 0L, (APTR)newfile,
  61.      NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
  62.      NM_ITEM, (STRPTR)"Add File", (STRPTR)"A", 0, 0L, (APTR)addClicked,
  63.      NM_ITEM, (STRPTR)"Kill Set", (STRPTR)"K", 0, 0L, (APTR)deleteClicked,
  64.      NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
  65.      NM_ITEM, (STRPTR)"Print", (STRPTR)"P", 0, 0L, (APTR)PlotDump,
  66.      NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
  67.      NM_ITEM, (STRPTR)"About", NULL, 0, 0L, (APTR)PlotWindowItem0,
  68.      NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
  69.      NM_ITEM, (STRPTR)"Die", (STRPTR)"Q", 0, 0L, (APTR)PlotWindowItem1,
  70.      NM_TITLE, (STRPTR)"Display", NULL, 0, NULL, NULL,
  71.      NM_ITEM, (STRPTR)"Full View", (STRPTR)"F", 0L, 0L, (APTR)fullClicked,
  72.      NM_ITEM, (STRPTR)"UnZoom", (STRPTR)"U", 0L, 0L, (APTR)UnZoom,
  73.      NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
  74.      NM_ITEM, (STRPTR)"Cross Hair", (STRPTR)"H", 0L, 0L, (APTR)CrossHair,
  75.      NM_ITEM, (STRPTR)"Significant Digits", (STRPTR)"D", 0L, 0L, (APTR)PreOpenRequest,
  76.      NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
  77.      NM_ITEM, (STRPTR)"Grid", (STRPTR)"G", NULL, 0L, (APTR)gridClicked,
  78.      NM_ITEM, (STRPTR)"Symbols", (STRPTR)"S", NULL, 0L, (APTR)PlotWindowItem6,
  79.      NM_ITEM, (STRPTR)"Control Panel", (STRPTR)"C", NULL, 0L, (APTR)PlotWindowItem7,
  80.      NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
  81.      NM_ITEM, (STRPTR)"Screen  Depth", NULL, 0, NULL, NULL,
  82.      NM_SUB, (STRPTR)"1", (STRPTR)"1", NULL, 0L, (APTR)NewDepth1,
  83.      NM_SUB, (STRPTR)"2", (STRPTR)"2", NULL, 0L, (APTR)NewDepth2,
  84.      NM_SUB, (STRPTR)"3", (STRPTR)"3", NULL, 0L, (APTR)NewDepth3,
  85.      NM_SUB, (STRPTR)"4", (STRPTR)"4", NULL, 0L, (APTR)NewDepth4,
  86.      NM_TITLE, (STRPTR)"Axis", NULL, 0, NULL, NULL,
  87.      NM_ITEM, (STRPTR)"XAxis", NULL, 0, NULL, NULL,
  88.      NM_SUB, (STRPTR)"Lin", NULL, 0, 0L, (APTR)PlotWindowItem2,
  89.      NM_SUB, (STRPTR)"Log", NULL, 0, 0L, (APTR)PlotWindowItem3,
  90.      NM_ITEM, (STRPTR)"YAxis", NULL, 0, NULL, NULL,
  91.      NM_SUB, (STRPTR)"Lin", NULL, 0, 0L, (APTR)PlotWindowItem4,
  92.      NM_SUB, (STRPTR)"Log", NULL, 0, 0L, (APTR)PlotWindowItem5,
  93.      NM_END, NULL, NULL, 0, 0L, NULL };
  94.  
  95.  
  96. UWORD PlotWindowGTypes[] = {
  97.      BUTTON_KIND,
  98.      BUTTON_KIND,
  99.      BUTTON_KIND,
  100.      BUTTON_KIND,
  101.      BUTTON_KIND,
  102.      BUTTON_KIND
  103. };
  104.  
  105. UWORD delwinGTypes[] = {
  106.      LISTVIEW_KIND,
  107.      BUTTON_KIND,
  108.      BUTTON_KIND
  109. };
  110.  
  111. UWORD PreSlideGTypes[] = {
  112.     SLIDER_KIND
  113. };
  114.  
  115. struct NewGadget PlotWindowNGad[] = {
  116.      NULL, NULL, NULL, NULL, (UBYTE *)"_Add", NULL, GD_add, PLACETEXT_IN, NULL, (APTR)addClicked,
  117.      NULL, NULL, NULL, NULL, (UBYTE *)"_Kill", NULL, GD_delete, PLACETEXT_IN, NULL, (APTR)deleteClicked,
  118.      NULL, NULL, NULL, NULL, (UBYTE *)"_Full", NULL, GD_full, PLACETEXT_IN, NULL, (APTR)fullClicked,
  119.      NULL, NULL, NULL, NULL, (UBYTE *)"_Zoom", NULL, GD_zoom, PLACETEXT_IN, NULL, (APTR)zoomClicked,
  120.      NULL, NULL, NULL, NULL, (UBYTE *)"_Hair", NULL, GD_grid, PLACETEXT_IN, NULL, (APTR)CrossHair,
  121.      NULL, NULL, NULL, NULL, (UBYTE *)"_Quit", NULL, GD_quit, PLACETEXT_IN, NULL, (APTR)quitClicked
  122. };
  123.  
  124. struct NewGadget delwinNGad[] = {
  125.      NULL, NULL, NULL, NULL, NULL, NULL, GD_dellist, NULL, NULL, (APTR)dellistClicked,
  126.      NULL, NULL, NULL, NULL, (UBYTE *)"_Kill", NULL, GD_delset, PLACETEXT_IN, NULL, (APTR)delsetClicked,
  127.      NULL, NULL, NULL, NULL, (UBYTE *)"_Redraw", NULL, GD_canlist, PLACETEXT_IN, NULL, (APTR)canlistClicked
  128. };
  129.  
  130. struct NewGadget PreSlideNGad[] = {
  131.     NULL, NULL, NULL, NULL, NULL, NULL, GD_pre, PLACETEXT_BELOW, NULL, (APTR)preClicked
  132. };
  133.  
  134.  
  135. ULONG PlotWindowGTags[] = {
  136.      (GT_Underscore), '_', (TAG_DONE),
  137.      (GT_Underscore), '_', (TAG_DONE),
  138.      (GT_Underscore), '_', (TAG_DONE),
  139.      (GT_Underscore), '_', (TAG_DONE),
  140.      (GT_Underscore), '_', (TAG_DONE),
  141.      (GT_Underscore), '_', (TAG_DONE)
  142. };
  143.  
  144. ULONG delwinGTags[] = {
  145.      (GTLV_ShowSelected), NULL, (TAG_DONE),
  146.      (GT_Underscore), '_', (TAG_DONE),
  147.      (GT_Underscore), '_', (TAG_DONE)
  148. };
  149.  
  150. ULONG PreSlideGTags[] = {
  151.     (GTSL_Min), 1, (GTSL_Max), 9, (GTSL_Level), NULL, (GTSL_MaxLevelLen), 3, (GTSL_LevelFormat), (ULONG)"%ld", (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE)
  152. };
  153.  
  154.  
  155. struct ColorSpec MonoColors[] = {
  156.       0, 0x02, 0x01, 0x05,
  157.       1, 0x0F, 0x0E, 0x0D,
  158.      ~0, 0x00, 0x00, 0x00 };
  159.  
  160. struct ColorSpec FourColors[] = {
  161.       0, 0x06, 0x07, 0x09,
  162.       1, 0x0B, 0x0A, 0x0A,
  163.       2, 0x03, 0x01, 0x03,
  164.       3, 0x0F, 0x06, 0x06,
  165.      ~0, 0x00, 0x00, 0x00 };
  166.  
  167. struct ColorSpec EightColors[] = {
  168.       0, 0x08, 0x07, 0x08,
  169.       1, 0x00, 0x00, 0x00,
  170.       2, 0x0C, 0x0C, 0x0F,
  171.       3, 0x09, 0x07, 0x08,
  172.       4, 0x0A, 0x07, 0x0F,
  173.       5, 0x0F, 0x0E, 0x08,
  174.       6, 0x04, 0x04, 0x07,
  175.       7, 0x0F, 0x0F, 0x0F,
  176.      ~0, 0x00, 0x00, 0x00 };
  177.  
  178. struct ColorSpec SixteenColors[] = {
  179.       0, 0x08, 0x07, 0x08,
  180.       1, 0x00, 0x00, 0x00,
  181.       2, 0x0F, 0x0F, 0x0F,
  182.       3, 0x07, 0x06, 0x09,
  183.       4, 0x08, 0x0B, 0x0F,
  184.       5, 0x00, 0x0E, 0x08,
  185.       6, 0x0F, 0x04, 0x08,
  186.       7, 0x0F, 0x0D, 0x07,
  187.       8, 0x0B, 0x07, 0x0F,
  188.       9, 0x0F, 0x0A, 0x08,
  189.      10, 0x0F, 0x08, 0x0D,
  190.      11, 0x06, 0x00, 0x0F,
  191.      12, 0x00, 0x0F, 0x0F,
  192.      13, 0x0F, 0x05, 0x00,
  193.      14, 0x05, 0x04, 0x07,
  194.      15, 0x0F, 0x0F, 0x0F,
  195.      ~0, 0x00, 0x00, 0x00 };
  196.  
  197.  
  198. int SetupScreen( void )
  199. {
  200. UBYTE PubNum[4];
  201. struct List    *publist;
  202. struct PubScreenNode *psnode;
  203. WORD  s=0,t;
  204. WORD len;
  205. struct ColorSpec *ScreenColors;
  206. UBYTE PubName[32];
  207.  
  208. UWORD DriPens[] = {
  209.      0,1,2,2,1,3,2,0,2,~0 };
  210.  
  211. UWORD TwoPens[] = {
  212.      0,1,2,1,2,3,2,0,2,~0 };
  213.  
  214.  
  215.      strcpy(PubName,MyName);  /* OpenScreen will fail if MyName has already been used */
  216.  
  217.      if ( Stricmp(PubName,&version_string[5])==0)     /** if user didn't supply us a name **/
  218.        {
  219.         strcpy(PubName,"cP");
  220.  
  221.         len = (WORD) strlen( PubName );
  222.  
  223.         publist = LockPubScreenList();                /* Lock the public screen list     */
  224.  
  225.         for (psnode = (struct PubScreenNode *) publist->lh_Head; psnode->psn_Node.ln_Succ; psnode = (struct PubScreenNode *) psnode->psn_Node.ln_Succ)
  226.           {
  227.               if ( ! Strnicmp( psnode-> psn_Node.ln_Name, PubName, len))
  228.                   {
  229.                    t = 0;
  230.                    sscanf( &psnode-> psn_Node.ln_Name [len],"%hd", &t);
  231.                    s = max(s,t);
  232.                 }
  233.           }
  234.  
  235.          UnlockPubScreenList ();
  236.  
  237.          sprintf( PubNum,"%hd", s+1 );
  238.          strcat ( PubName, PubNum);         /* Add #s of other cP screens to name */
  239.       }
  240.  
  241.      if ( depth == 1 ) ScreenColors = &MonoColors[0];
  242.      if ( depth == 2 ) ScreenColors = &FourColors[0];
  243.      if ( depth == 3 ) ScreenColors = &EightColors[0];
  244.      if ( depth == 4 ) ScreenColors = &SixteenColors[0];
  245.  
  246.      if ( depth == 1 )
  247.        {
  248.           DriPens[0] = ~0;
  249.        }
  250.  
  251.  
  252.      if ( ! ( Scr = OpenScreenTags( NULL, SA_Left,     0,
  253.                          SA_Top,        0,
  254.                          SA_Width,      SWIDTH,
  255.                          SA_Height,     SHEIGHT,
  256.                          SA_Depth,      depth,
  257.                          SA_Colors,     ScreenColors,
  258.                          SA_Behind,    BEHIND,
  259.                          SA_Font,       cPFont,
  260.                          SA_Type,       PUBLICSCREEN,
  261.                          SA_PubName,    PubName,
  262.                          SA_DisplayID,  DEFAULT_MONITOR_ID | Disp,
  263.                          SA_Overscan,   OSCAN_TEXT,
  264.                          SA_AutoScroll, TRUE,
  265.                          SA_Pens,       (depth == 2 ? &TwoPens[0] : &DriPens[0]),
  266.                          SA_Title,      &version_string[5],
  267.                          TAG_DONE )))
  268.           return( 1L );
  269.  
  270.      if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
  271.           return( 2L );
  272.  
  273.      PubScreenStatus( Scr, NULL );      /* make screen public */
  274.      if ( DEFS ) SetDefaultPubScreen( PubName );  /* make screen default pub if DEFS True */
  275.  
  276.      SetRGB4( &Scr-> ViewPort, 17,7, 8,15);  /* set colors for pointerz */
  277.      SetRGB4( &Scr-> ViewPort, 18,15,11,9);
  278.      SetRGB4( &Scr-> ViewPort, 19,15,0,10);
  279.  
  280.      vp = &(Scr-> ViewPort);
  281.  
  282.      return( 0L );
  283. }
  284.  
  285. void CloseDownScreen( void )
  286. {
  287. struct EasyStruct myezreq = {
  288.        sizeof (struct EasyStruct), 0,
  289.        "Close Public Screen",
  290.        "Close All Windows on this Screen",
  291.        "OK"
  292.   };
  293.  
  294.      if ( VisualInfo ) {
  295.           FreeVisualInfo( VisualInfo );
  296.           VisualInfo = NULL;
  297.      }
  298.      if ( Scr ) {
  299.  
  300.           PubScreenStatus( Scr, PSNF_PRIVATE );   /* make the screen unavailable */
  301.  
  302.           while( ! CloseScreen( Scr ))
  303.             {
  304.                Forbid();
  305.                EasyRequestArgs( Scr-> FirstWindow, &myezreq, NULL, NULL );
  306.                Permit();
  307.             }
  308.  
  309.      }
  310.      Scr = NULL;
  311. }
  312.  
  313. int HandlePlotWindowIDCMP( void )
  314. {
  315.      struct IntuiMessage *m;
  316.      struct MenuItem          *n;
  317.      int            (*func)();
  318.      BOOL           running = TRUE;
  319.  
  320.      while( m = GT_GetIMsg( PlotWindowWnd->UserPort )) {
  321.  
  322.           CopyMem(( char * )m, ( char * )&PlotWindowMsg, (long)sizeof( struct IntuiMessage ));
  323.  
  324.           GT_ReplyIMsg( m );
  325.  
  326.           switch ( PlotWindowMsg.Class ) {
  327.  
  328.                case IDCMP_REFRESHWINDOW:
  329.                     GT_BeginRefresh( PlotWindowWnd );
  330.                     GT_EndRefresh( PlotWindowWnd, TRUE );
  331.                     break;
  332.  
  333.                case IDCMP_VANILLAKEY:
  334.                     running = PlotWindowVanillaKey();
  335.                     break;
  336.  
  337.                case IDCMP_RAWKEY:
  338.                     running = PlotWindowRawKey();
  339.                     break;
  340.  
  341.                case IDCMP_MOUSEBUTTONS:
  342.                     if (PlotWindowMsg.Code == SELECTDOWN)
  343.                       {
  344.                          running = Measure(PlotWindowMsg.MouseX, PlotWindowMsg.MouseY);
  345.                      }
  346.                     break;
  347.  
  348.                case IDCMP_GADGETUP:
  349.                     func = ( void * )(( struct Gadget * )PlotWindowMsg.IAddress )->UserData;
  350.                     running = func();
  351.                     break;
  352.  
  353.                case IDCMP_MENUPICK:
  354.                     while( PlotWindowMsg.Code != MENUNULL ) {
  355.                          n = ItemAddress( PlotWindowMenus, PlotWindowMsg.Code );
  356.                          func = (void *)(GTMENUITEM_USERDATA( n ));
  357.                          running = func();
  358.                          PlotWindowMsg.Code = n->NextSelect;
  359.                     }
  360.                     break;
  361.           }
  362.      }
  363.      return( running );
  364. }
  365.  
  366. int OpenPlotWindowWindow( void )
  367. {
  368.      struct NewGadget    ng;
  369.      struct Gadget  *g;
  370.      UWORD          lc, tc;
  371.      WORD   GadTop;
  372.     WORD BORD = 3; /* pixels at edge and bottom of control panel */
  373.  
  374.      if ( ! ( g = CreateContext( &PlotWindowGList )))
  375.           return( 1L );
  376.  
  377.      GADWIDTH  = ( Scr-> Width - 2*BORD ) / PlotWindow_CNT;
  378.      GADHEIGHT = cPFont->ta_YSize * 2;
  379.  
  380.      GadTop = Scr-> Height - Scr-> BarHeight -1  - cPFont->ta_YSize * 2 - BORD;
  381.  
  382.      for( lc = 0, tc = 0; lc < PlotWindow_CNT; lc++ ) {
  383.  
  384.           PlotWindowNGad[ lc ] . ng_LeftEdge = GADWIDTH * lc + BORD;
  385.           PlotWindowNGad[ lc ] . ng_Width    = GADWIDTH;
  386.           PlotWindowNGad[ lc ] . ng_TopEdge  = GadTop;
  387.           PlotWindowNGad[ lc ] . ng_Height   = GADHEIGHT;
  388.  
  389.           CopyMem((char * )&PlotWindowNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  390.  
  391.           ng.ng_VisualInfo = VisualInfo;
  392.           ng.ng_TextAttr   = cPFont;
  393.  
  394.           PlotWindowGadgets[ lc ] = g = CreateGadgetA((ULONG)PlotWindowGTypes[ lc ], g, &ng, ( struct TagItem * )&PlotWindowGTags[ tc ] );
  395.  
  396.           while( PlotWindowGTags[ tc ] ) tc += 2;
  397.           tc++;
  398.  
  399.           if ( NOT g )
  400.                return( 2L );
  401.      }
  402.  
  403.      if ( ! ( PlotWindowMenus = CreateMenus( PlotWindowNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
  404.           return( 3L );
  405.  
  406.      LayoutMenus( PlotWindowMenus, VisualInfo, GTMN_TextAttr, cPFont, TAG_DONE );
  407.  
  408.  
  409.      if ( ! ( PlotWindowWnd = OpenWindowTags( NULL,
  410.                     WA_Left,  0,
  411.                     WA_Top,        Scr-> BarHeight+1,
  412.                     WA_Width, Scr-> Width,
  413.                     WA_Height,     Scr-> Height - (Scr-> BarHeight+1),
  414.                     WA_IDCMP, BUTTONIDCMP|IDCMP_MOUSEMOVE|IDCMP_MOUSEBUTTONS|IDCMP_MENUPICK|IDCMP_RAWKEY|IDCMP_VANILLAKEY,
  415.                     WA_Flags,     WFLG_SMART_REFRESH|WFLG_BACKDROP|WFLG_BORDERLESS,
  416.                     WA_Activate,   ( BEHIND ? FALSE : TRUE),
  417.                     WA_Gadgets,    ( CPANEL ? PlotWindowGList : NULL),
  418.                     WA_ScreenTitle,     MyName,
  419.                     WA_RptQueue,        0,
  420.                     WA_AutoAdjust, TRUE,
  421.                     WA_PubScreen,  Scr,
  422.                     TAG_DONE )))
  423.      return( 4L );
  424.  
  425.      SetMenuStrip( PlotWindowWnd, PlotWindowMenus );
  426.      GT_RefreshWindow( PlotWindowWnd, NULL );
  427.  
  428.      rp = PlotWindowWnd-> RPort;
  429.  
  430.      PlotWindowWnd-> RPort-> Font = fontPtr;
  431.  
  432.     BEHIND = FALSE;
  433.  
  434.      return( 0L );
  435. }
  436.  
  437. void ClosePlotWindowWindow( void )
  438. {
  439.      if ( PlotWindowMenus      ) {
  440.           ClearMenuStrip( PlotWindowWnd );
  441.           FreeMenus( PlotWindowMenus );
  442.           PlotWindowMenus = NULL;  }
  443.  
  444.      if ( PlotWindowWnd        ) {
  445.           CloseWindow( PlotWindowWnd );
  446.           PlotWindowWnd = NULL;
  447.      }
  448.  
  449.      if ( PlotWindowGList      ) {
  450.           FreeGadgets( PlotWindowGList );
  451.           PlotWindowGList = NULL;
  452.      }
  453. }
  454.  
  455. int HandledelwinIDCMP( void )
  456. {
  457.      struct IntuiMessage *m;
  458.      int            (*func)();
  459.      BOOL           running = TRUE;
  460.  
  461.      while( m = GT_GetIMsg( delwinWnd->UserPort )) {
  462.  
  463.           CopyMem(( char * )m, ( char * )&delwinMsg, (long)sizeof( struct IntuiMessage ));
  464.  
  465.           GT_ReplyIMsg( m );
  466.  
  467.           switch ( delwinMsg.Class ) {
  468.  
  469.                case IDCMP_REFRESHWINDOW:
  470.                     GT_BeginRefresh( delwinWnd );
  471.                     GT_EndRefresh( delwinWnd, TRUE );
  472.                     break;
  473.  
  474.                case IDCMP_CLOSEWINDOW:
  475.                     running = delwinCloseWindow();
  476.                     break;
  477.  
  478.                case IDCMP_VANILLAKEY:
  479.                     running = delwinVanillaKey();
  480.                     break;
  481.  
  482.                case IDCMP_RAWKEY:
  483.                     running = delwinRawKey();
  484.                     break;
  485.  
  486.                case IDCMP_GADGETUP:
  487.                case IDCMP_GADGETDOWN:
  488.                     func = ( void * )(( struct Gadget * )delwinMsg.IAddress )->UserData;
  489.                     running = func();
  490.                     break;
  491.           }
  492.      }
  493.      return( running );
  494. }
  495.  
  496. int OpendelwinWindow( void )
  497. {
  498.      struct NewGadget    ng;
  499.      struct Gadget  *g;
  500.      UWORD          lc, tc;
  501.      UWORD          offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  502.      WORD           xo, yo;
  503.      struct Rectangle rect;
  504.     
  505.  
  506.     delwinWidth  = fontPtr->tf_XSize * 26;
  507.     delwinHeight = cPFont->ta_YSize * 12;
  508.  
  509.     if (QueryOverscan(Disp, &rect, OSCAN_TEXT))
  510.       {
  511.  
  512.          xo = -Scr->ViewPort.DxOffset+(rect.MaxX-rect.MinX)/2 - delwinWidth/2;
  513.          yo = -Scr->ViewPort.DyOffset+(rect.MaxY-rect.MinY)/2 - delwinHeight/2;
  514.           }
  515.     else xo = yo = 100;
  516.  
  517.      if ( ! ( g = CreateContext( &delwinGList )))
  518.           return( 1L );
  519.  
  520.     delwinNGad[ 0 ] . ng_LeftEdge = Scr->WBorLeft;
  521.      delwinNGad[ 0 ] . ng_Width    = delwinWidth - Scr->WBorLeft - Scr->WBorRight;
  522.      delwinNGad[ 0 ] . ng_TopEdge  = offy;
  523.      delwinNGad[ 0 ] . ng_Height   = delwinHeight-(2*cPFont->ta_YSize) - offy;
  524.  
  525.     delwinNGad[ 1 ] . ng_LeftEdge = Scr->WBorLeft;
  526.      delwinNGad[ 1 ] . ng_Width    = (delwinWidth - Scr->WBorLeft - Scr->WBorRight)/2;
  527.      delwinNGad[ 1 ] . ng_TopEdge  = delwinHeight-(2*cPFont->ta_YSize) - Scr->WBorBottom ;
  528.      delwinNGad[ 1 ] . ng_Height   = (2*cPFont->ta_YSize);
  529.  
  530.     delwinNGad[ 2 ] . ng_LeftEdge = (delwinWidth - Scr->WBorLeft - Scr->WBorRight)/2 + Scr->WBorLeft;
  531.      delwinNGad[ 2 ] . ng_Width    = (delwinWidth - Scr->WBorLeft - Scr->WBorRight)/2;
  532.      delwinNGad[ 2 ] . ng_TopEdge  = delwinHeight-(2*cPFont->ta_YSize) - Scr->WBorBottom ;
  533.      delwinNGad[ 2 ] . ng_Height   = (2*cPFont->ta_YSize);
  534.  
  535.  
  536.      for( lc = 0, tc = 0; lc < delwin_CNT; lc++ ) {
  537.  
  538.           CopyMem((char * )&delwinNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  539.  
  540.           ng.ng_VisualInfo = VisualInfo;
  541.           ng.ng_TextAttr   = cPFont;
  542.  
  543.           delwinGadgets[ lc ] = g = CreateGadgetA((ULONG)delwinGTypes[ lc ], g, &ng, ( struct TagItem * )&delwinGTags[ tc ] );
  544.  
  545.           while( delwinGTags[ tc ] ) tc += 2;
  546.           tc++;
  547.  
  548.           if ( NOT g )
  549.                return( 2L );
  550.      }
  551.  
  552.      if ( ! ( delwinWnd = OpenWindowTags( NULL,
  553.                     WA_Left, xo,
  554.                     WA_Top, yo,
  555.                     WA_Width, delwinWidth,
  556.                     WA_Height,     delwinHeight,
  557.                     WA_IDCMP, LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_RAWKEY,
  558.                     WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  559.                     WA_Gadgets,    delwinGList,
  560.                     WA_Title, delwinWdt,
  561.                     WA_ScreenTitle,     MyName,
  562.                     WA_PubScreen,  Scr,
  563.                     TAG_DONE )))
  564.      return( 4L );
  565.  
  566.      GT_RefreshWindow( delwinWnd, NULL );
  567.  
  568.  
  569.      return( 0L );
  570. }
  571.  
  572. void ClosedelwinWindow( void )
  573. {
  574.      if ( delwinWnd        ) {
  575.           CloseWindow( delwinWnd );
  576.           delwinWnd = NULL;
  577.      }
  578.  
  579.      if ( delwinGList      ) {
  580.           FreeGadgets( delwinGList );
  581.           delwinGList = NULL;
  582.      }
  583. }
  584.  
  585. int HandlePreSlideIDCMP( void )
  586. {
  587.     struct IntuiMessage    *m;
  588.     int            (*func)();
  589.     BOOL            running = TRUE;
  590.  
  591.     while( m = GT_GetIMsg( PreSlideWnd->UserPort )) {
  592.  
  593.         CopyMem(( char * )m, ( char * )&PreSlideMsg, (long)sizeof( struct IntuiMessage ));
  594.  
  595.         GT_ReplyIMsg( m );
  596.  
  597.         switch ( PreSlideMsg.Class ) {
  598.  
  599.             case    IDCMP_CLOSEWINDOW:
  600.                 running = PreSlideCloseWindow();
  601.                 break;
  602.  
  603.             case    IDCMP_GADGETUP:
  604.             case    IDCMP_GADGETDOWN:
  605.                 func = ( void * )(( struct Gadget * )PreSlideMsg.IAddress )->UserData;
  606.                 running = func();
  607.                 break;
  608.         }
  609.     }
  610.     return( running );
  611. }
  612.  
  613. int OpenPreSlideWindow( void )
  614. {
  615.     struct NewGadget    ng;
  616.     struct Gadget    *g;
  617.     UWORD          PreSlideWidth = 300;
  618.     UWORD          PreSlideHeight = 50;
  619.  
  620.     if ( ! ( g = CreateContext( &PreSlideGList )))
  621.         return( 1L );
  622.  
  623.     CopyMem((char * )&PreSlideNGad[ 0 ], (char * )&ng, (long)sizeof( struct NewGadget ));
  624.  
  625.     PreSlideWidth += Scr->BarHeight + fontPtr->tf_XSize;
  626.     PreSlideHeight += cPFont->ta_YSize;
  627.  
  628.     ng.ng_VisualInfo = VisualInfo;
  629.     ng.ng_TextAttr   = cPFont;
  630.     ng.ng_LeftEdge   = 40 + fontPtr->tf_XSize;
  631.     ng.ng_TopEdge    = 20 + Scr->BarHeight;
  632.     ng.ng_Width      = 220;
  633.     ng.ng_Height     = 20;
  634.  
  635.     PreSlideGTags[ 5 ] = precision+1;
  636.  
  637.     PreSlideGadgets[ 0 ] = g = CreateGadgetA((ULONG)PreSlideGTypes[ 0 ], g, &ng, ( struct TagItem * )&PreSlideGTags[ 0 ] );
  638.  
  639.     if ( NOT g )
  640.         return( 2L );
  641.  
  642.     if ( ! ( PreSlideWnd = OpenWindowTags( NULL,
  643.                 WA_Left,    Scr->Width/2 - PreSlideWidth/2,
  644.                 WA_Top,    Scr->Height/2 - PreSlideHeight/2,
  645.                 WA_Width,    PreSlideWidth,
  646.                 WA_Height,    PreSlideHeight + Scr->BarHeight ,
  647.                 WA_IDCMP,    SLIDERIDCMP|IDCMP_CLOSEWINDOW,
  648.                 WA_Flags,    WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  649.                     WA_PubScreen,  Scr,
  650.                 WA_Gadgets,    PreSlideGList,
  651.                 WA_Title,    PreSlideWdt,
  652.                 WA_ScreenTitle,    "Enter Significant Digits",
  653.                 TAG_DONE )))
  654.     return( 4L );
  655.  
  656.     GT_RefreshWindow( PreSlideWnd, NULL );
  657.  
  658.     return( 0L );
  659. }
  660.  
  661. void ClosePreSlideWindow( void )
  662. {
  663.     if ( PreSlideWnd        ) {
  664.         CloseWindow( PreSlideWnd );
  665.         PreSlideWnd = NULL;
  666.     }
  667.  
  668.     if ( PreSlideGList      ) {
  669.         FreeGadgets( PreSlideGList );
  670.         PreSlideGList = NULL;
  671.     }
  672.  
  673. }
  674.  
  675.