/* ===========================================================================

  trackFunc.h    Global variables and functions for Manual track editing mode

=============================================================================*/
#ifdef TRACK_FUNC_ALLOCATE
#define EXTERN
#else
#define EXTERN extern
#endif


class TrackFunc 
{
public:
  TrackFunc(void);                         /* Constructor */
  void  buttonDown(SINT4 x_a, SINT4 y_a);  /* Button 1 was pressed */
  void  buttonDrag(SINT4 x_a, SINT4 y_a);  /* Button 1 was dragged */
  void  buttonUp(SINT4 x_a, SINT4 y_a);    /* Button 1 was released */
  void  enterMode( void );                 /* Entering track mode */
  void  exitMode( void );                  /* Exiting track mode */
  
  void  setName( const char *sName_a );    /* New track name was selected */
  void  setAction( UINT4 iAction_a );      /* New action was selected */
  void  textTyped( const char *stext_a );  /* New text string was typed in */
  void  setTextSize( UINT4 iSize_a );      /* New text size selected */
  void  setTextColor( UINT4 iColor_a );    /* New text color selected */
  void  setIcon( const char *sIcon_a );    /* New icon selected */
  
  void  plantTarget( void );               /* "Plant target" button was pressed */
  void  setForecastTime( UINT4 iSeconds_a ); /* New forecast time was entered */

  void  newProduct( void );                /* New product on the screen */
  void  notifyPeerEntered( void );         /* Another tool was entered */
  void  notifyHomeChanged                  /* Home point was changed */
    ( const struct home_point *pHome_a );
  void  getTrackName                       /* Set track name to be used for output */
    ( char sTrackName_a[16] );
  void  processServerReply                 /* Process server reply strings */
    ( char *stoks_a[8], char *pdata, SINT4 isize );
  void  HeaderFromOnScreen
    (struct product_hdr *phdr_a,
     UINT2 iPType_a,             /* Product type for product */
     const char *sPName_a );     /* PCO name for product, null terminated*/
  void PCFFromOnScreen
    (struct product_configuration *pcf_a,
     UINT2 iPType_a,             /* Product type for product */
     const char *sPName_a );     /* PCO name for product, null terminated*/

#define TRACK_MODE_ADD       0             /* Next button press adds a point */
#define TRACK_MODE_TEXT      1             /* Next button press adds a text point */
#define TRACK_MODE_ICON      2             /* Next button press adds an icon point */
#define TRACK_MODE_TARGET    3             /* Next button press moves the target point */
#define TRACK_MODE_DELETE    4             /* Next button press deletes a point */
#define TRACK_MODE_DELETEALL 5             /* Delete all the points */
  
private:
#ifdef TRACK_FUNC_ALLOCATE
  UINT2 lInTrackMode_c;
  UINT2 lValidProduct_c;                   /* Current product is valid as a base */
  char  sPName_c[16];                      /* Current Track product name */
  char  sText_c[32];                       /* Current text string to add */
  char  sIcon_c[ICON_NAME_SIZE];           /* Current text string to add */
  UINT4 iTextSize_c;                       /* Current text size */
  UINT4 iColor_c;                          /* Current text color */
  UINT4 iSubMode_c;                        /* Submode we are in */
  struct product_hdr *pTrackFile_c;        /* Pointer to the track file contents */
  const struct track_results *pLastPoint_c;/* Last point of the track, (NULL if none) */
  UINT2 LoadName              /* Loads up new name or product */
    (UINT2 lNewName_a );
  void  addAPoint
    ( const FLT4 fPos_a[2] );
  void DeleteAPoint
    ( SINT4 iIndex_a );       /* Index of point, origin 1 */
  void  GenerateNewPoint
    (const FLT4 fPos_a[2], struct track_results *track_point_a );
  SINT4 FindOldPoint          /* Find the neareset point */
    (const FLT4 fPos_a[2],
     SINT4 iOldPos_a[2] );
  void setHome
    ( const struct home_point *pHome_a );
  void  updateTrackMenu( void );           /* Updates the menu numbers */
  void  setInvalidText(void);
  void  updateToTargetPortion
    ( const struct home_point *pHome_a );
  void  processOpenReply
    (const struct product_hdr *pData_a, SINT4 iSize_a );
  void  deleteAllPoints( void );           /* Delete all the points */
#endif  /* #ifdef TRACK_FUNC_ALLOCATE */
  
};
EXTERN TrackFunc trackFunc;

#undef EXTERN
