#ifndef PRECOGNITION_UTILS_H
#define PRECOGNITION_UTILS_H

#include <intuition/intuition.h>
#include "intuition_typedefs.h"

#ifndef PRECOGNITION_UTILS_BODY
extern TextAttr pcg_Topaz80;
#endif


BOOL is_Workbench_v2( void );
   /* returns TRUE if you're running Workbench 2.0 */
   

tPoint pcg_GadgetRelativeCoords( Gadget       *gadget,
                                 IntuiMessage *event );
/* Translates the MouseX, MouseY coordinates of a gadget-related
 * IntuiMessage into coordinates which are relative to the gadget
 * (instead of the window.)
 */


tPoint pcg_AspectRatio( USHORT ViewModes );
/* Returns the aspect ration of a screen with the supplied viewmodes.
 * i.e.  LO-RES            = 1 : 1
 *       LORES INTERLACE   = 1 : 2
 *       HIRES             = 2 : 1
 *       HIRES INTERLACE   = 1 : 1
 */

void SetWaitPointer( Window *w );
/* changes the pointer to the standard 2.0 'clock' wait pointer. */

void ChainGadgets( Gadget *start_of_chain, Gadget *gadget );

IntuiMessage *WaitForMsg( struct MsgPort *mport );

Window *OpenWindowWithSharedPort( struct NewWindow *nw,
                                  struct MsgPort   *shared );

void CloseWindowSafely( Window *w ); /* Taken from 1.3 RKM:L&D, page 171 */




typedef struct AlignInfo   /* Used for alignment of text to objects */
{
   UBYTE Flags;
   BYTE  Xpad;
   BYTE  Ypad;
} AlignInfo;

/* Text Alignment Flags */
#define tx_LEFT      1
#define tx_XCENTER   2
#define tx_RIGHT     4
#define tx_TOP       8
#define tx_YCENTER   16
#define tx_BOTTOM    32
#define tx_INSIDE    64
#define tx_OUTSIDE   128

#define STD_XPAD 4   /* Standard XPad value. */
#define STD_YPAD 2   /* Standard YPad value. */


/*
** This is a 'value added' version of 'struct IntuiText'
**
** An 'AlignInfo' structure is appended to the end of the
** IntuiText data.  This information allows an object to
** intelligently reposition of the text when the object
** is resized.
*/

typedef struct PrecogText
{
   UBYTE             FrontPen,
                     BackPen;   /* the pen numbers for the rendering */
   UBYTE             DrawMode;  /* the mode for rendering the text */
   SHORT             LeftEdge;  /* relative start location for the text */
   SHORT             TopEdge;   /* relative start location for the text */
   struct TextAttr  *ITextFont; /* if NULL, you accept the default */
   UBYTE            *IText;     /* pointer to null-terminated text */
   struct IntuiText *NextText;  /* continuation to TxWrite another text */

   AlignInfo         alignment;
} PrecogText;


void AlignText( PrecogText        *ptext,
                Point              size );
   /*
   ** Aligns text 'ptext' relative to an object of
   ** dimensions 'size'.
   */

#endif
