home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / ACC / OUTLINE.ACC / PATH.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  7.5 KB  |  286 lines

  1. /* ===================================================================
  2.  * FILE: PATH.C
  3.  * ===================================================================
  4.  * DATE: December  9, 1992    Combine bitmap and outline fonts
  5.  *     December 15, 1992     Remove Bitmap and devices
  6.  *     January  21, 1993    Update Current.FontPath when
  7.  *                switching to directories.
  8.  * 
  9.  * DESCRIPTION: Fonts ACC
  10.  *
  11.  * This file handles the path dialog box.
  12.  *
  13.  * COMPILER: TURBO C Version 2.0
  14.  */
  15.  
  16.  
  17. /* INCLUDE FILES
  18.  * ===================================================================
  19.  */
  20. #include <sys\gemskel.h>
  21. #include <tos.h>
  22. #include <linea.h>
  23. #include <string.h>
  24. #include <stdio.h>
  25.  
  26. #include "country.h"
  27. #include "fonthead.h"
  28. #include "fonts.h"
  29. #include "mainstuf.h"
  30. #include "text.h"
  31. #include "fsmio.h"
  32. #include "mover.h"
  33. #include "front.h"
  34.  
  35.  
  36.  
  37. /* STRUCTURES
  38.  * ===================================================================
  39.  */
  40.  
  41.  
  42. /* EXTERN
  43.  * ===================================================================
  44.  */
  45. extern int AES_Version;
  46.  
  47.  
  48.  
  49. /* PROTOTYPES
  50.  * ===================================================================
  51.  */
  52. void    DoPath( void );
  53. int    HandlePath( int button, WORD *msg );
  54. void    wait_up( void );
  55.  
  56.  
  57.  
  58.  
  59. /* DEFINES
  60.  * ===================================================================
  61.  */
  62. #define DIR_MAX        30
  63. #define FRONT_HEIGHT  14
  64.  
  65.  
  66.  
  67. /* GLOBALS
  68.  * ===================================================================
  69.  */
  70. char outdirpath[ 128 ];
  71. char outnewpath[ 128 ];
  72. char outbackup[ 128 ];
  73. char outview_path[ 128 ];
  74. int  outdircount;
  75. int  outdirsize;
  76.  
  77. char underbar[] = "______________________________";
  78.  
  79.  
  80. /* FUNCTIONS
  81.  * ===================================================================
  82.  */
  83.  
  84.  
  85. /* DoPath()
  86.  * ===================================================================
  87.  */
  88. void
  89. DoPath( void )
  90. {
  91.     Reset_Tree( ad_path );
  92.  
  93.     /* Setup the Outline Font Path Variables */
  94.     strcpy( outbackup, OutlinePath );
  95.     strcpy( outdirpath, OutlinePath );
  96.     strcat( outdirpath, "\\*.SPD");
  97.     outdircount = 0;
  98.     outdirsize  = ( int )strlen( &outdirpath[0] );
  99.      
  100.     strcpy( outview_path, underbar );
  101.     strncpy( outview_path, outdirpath, min( DIR_MAX, outdirsize ) );
  102.     if( outdirsize > DIR_MAX )
  103.        outview_path[ DIR_MAX - 1 ] = 0xAF;
  104.  
  105.     TedText( OPATHS ) = outview_path;
  106.     
  107.     Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  108. }
  109.  
  110.  
  111.  
  112. /* HandlePath()
  113.  * ===================================================================
  114.  */
  115. int
  116. HandlePath( int button, WORD *msg )
  117. {
  118.    int     quit;
  119.    MRETS   mk;
  120.    long    i;
  121.    int     out;
  122.    
  123.    quit   = FALSE;
  124.  
  125.    
  126.    /* Handle Double-clicking of the objects */   
  127.    if( ( button != -1 ) && ( button & 0x8000 ) )
  128.       button &= 0x7FFF;
  129.    
  130.    switch( button )
  131.    {
  132.      case PEXIT:    Deselect( PEXIT );
  133.                  if( strcmp( OutlinePath, outbackup ) )
  134.                  {
  135.                  
  136.                   MF_Save();     
  137.               Scan_Message( ad_scan, TRUE );
  138.               /* REad the ACTIVE Fonts Only */
  139.               read_fonts( FALSE, TRUE );
  140.               Scan_Message( ad_scan, FALSE );
  141.               MF_Restore();
  142.             
  143.                    SetChangeFlag();
  144.             
  145.               ActiveTree( ad_front );
  146.                       mover_setup( installed_list, installed_count,
  147.                            FBASE, FSLIDER, FUP, FDOWN,
  148.                      LINE0, LINE9, LINEBASE, 0, FRONT_HEIGHT );
  149.               ActiveTree( ad_options );
  150.  
  151.                    /* Set Current.FontPath to OutlinePath */
  152.               strcpy( Current.FontPath, OutlinePath );
  153.             }
  154.             
  155.             
  156.             Reset_Tree( ad_options );
  157.             /* if the path has changed, we need to clear
  158.              * the total # of fonts box.
  159.              */
  160.             if( !Fonts_Loaded )
  161.             {
  162.                HideObj( OTITLE3 );
  163.                HideObj( OBASE );
  164.             }   
  165.             Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  166.                  break;
  167.                  
  168.      case PCANCEL:  Deselect( PCANCEL );
  169.                  strcpy( OutlinePath, outbackup );
  170.                  
  171.             Reset_Tree( ad_options );     
  172.             Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  173.                  break;
  174.                  
  175.  
  176.      case OLEFT:    XSelect( tree, OLEFT );
  177.                  do
  178.                  {
  179.                     Graf_mkstate( &mk );
  180.                     if( outdircount )
  181.                     {
  182.                       outdircount--;
  183.                       strncpy( outview_path, &outdirpath[ outdircount ], min( DIR_MAX, outdirsize - outdircount ) );
  184.                       if( outdircount )
  185.                            outview_path[0] = 0xAE;
  186.                       if((outdirsize - outdircount ) > DIR_MAX )
  187.                            outview_path[ DIR_MAX - 1 ] = 0xAF;
  188.                       TedText( OPATHS ) = outview_path;
  189.                       Objc_draw( tree, OPATHS, MAX_DEPTH, NULL );
  190.                     }  
  191.                  }while( mk.buttons );
  192.                  XDeselect( tree, OLEFT );
  193.                  break;
  194.                  
  195.      case ORIGHT:   XSelect( tree, ORIGHT );
  196.                  do
  197.                  {
  198.                     Graf_mkstate( &mk );
  199.                  if( ( outdirsize > DIR_MAX ) && ((outdircount + DIR_MAX ) < outdirsize ))
  200.                  {
  201.                     outdircount++;
  202.                     strncpy( outview_path, &outdirpath[ outdircount], min( DIR_MAX, outdirsize - outdircount) );
  203.                     outview_path[0] = 0xAE;
  204.                     if( (outdirsize - outdircount) > DIR_MAX )
  205.                         outview_path[ DIR_MAX - 1 ] = 0xAF;
  206.                     TedText( OPATHS ) = outview_path;
  207.                     Objc_draw( tree, OPATHS, MAX_DEPTH, NULL );
  208.                  }                   
  209.                  }while( mk.buttons );
  210.                  XDeselect( tree, ORIGHT );
  211.                  break;
  212.                  
  213.      case OPATHS:   XSelect( tree, OPATHS );
  214.                  wait_up();
  215.                 strcpy( outnewpath, outdirpath );
  216.                 for( i = strlen( outnewpath ); i && ( outnewpath[i] != '\\'); outnewpath[ i-- ] = '\0' );
  217.                  out = fsel_name( FALSE, outnewpath, "*.SPD", dtext );
  218.                  if( ( ( out == A_OK ) || ( out == A_CANCEL )) && ( outnewpath[0] != '\0' ) )
  219.                  {
  220.                       for( i = strlen( outnewpath ); i && ( outnewpath[i] != '\\'); outnewpath[ i-- ] = '\0' );
  221.                       
  222.                    strcpy( outdirpath, outnewpath );
  223.                    
  224.                    outnewpath[i] = '\0';    /* Get rid of the '\\' */
  225.                    strcpy( OutlinePath, outnewpath );
  226.                    
  227.                    strcat( outdirpath, "*.SPD" );
  228.                    outdirsize = (int)strlen( &outdirpath[0] );
  229.                    strcpy( outview_path, underbar );
  230.                    strncpy( outview_path, outdirpath, min( DIR_MAX, outdirsize) );
  231.                    outdircount = 0;
  232.                    if( outdirsize > DIR_MAX )
  233.                       outview_path[ DIR_MAX - 1 ] = 0xAF;
  234.                  TedText( OPATHS ) = outview_path;
  235.             }
  236.             XDeselect( tree, OPATHS );
  237.             break;
  238.  
  239.  
  240.      default:     if( button == -1 )
  241.               {
  242.                 switch( msg[0] )
  243.                 {
  244.                   case WM_REDRAW: 
  245.                                break;
  246.                                    
  247.                   case AC_CLOSE:  quit = TRUE;
  248.                                break;
  249.                                        
  250.                   case WM_CLOSED: quit = TRUE;
  251.                           if( strcmp( OutlinePath, outbackup ) )
  252.                               {
  253.                                   strcpy( Current.FontPath, OutlinePath );
  254.                              SetChangeFlag();
  255.                           }     
  256.                                CloseWindow();
  257.                      break;
  258.  
  259.              case CT_KEY:
  260.                           break;
  261.                   default:
  262.                           break;
  263.                 }
  264.               }
  265.               break;
  266.    }
  267.    return( quit );
  268.  
  269.  
  270. }
  271.  
  272.  
  273.  
  274.  
  275. /* wait_up()
  276.  *==========================================================================
  277.  * Wait for an up button.
  278.  */
  279. void
  280. wait_up( void )
  281. {
  282.    MRETS m;
  283.    
  284.    Evnt_button( 1, 1, 0, &m );
  285. }
  286.