#ifndef __Coords__H
#define __Coords__H

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef int32_t file_type;
typedef uint32_t HWind;
typedef int32_t HIcon; // signed cf system icons
typedef uint32_t HTask;

#define HWind_None    0xffffffff
#define HWind_IconBar 0xfffffffe
#define HIcon_None    -1
#define HTask_None    0

typedef struct CMenu CMenu;

typedef CMenu* HMenu;

typedef struct CRect
{
	int x0;
	int y0;
	int x1;
	int y1;
} CRect;

typedef struct CSize
{
	int cx;
	int cy;
} CSize;

typedef struct CPoint
{
	int x;
	int y;
} CPoint;

typedef struct
{
	HWind  w;
	HIcon  i;
	CPoint pt;
} ScreenPos;

#define EBut_Adjust      0x001
#define EBut_Menu        0x002
#define EBut_Select      0x004
#define EBut_DragAdjust  0x010
#define EBut_DragSelect  0x040
#define EBut_ClickAdjust 0x100
#define EBut_ClickSelect 0x400

typedef struct
{
	CPoint   pt;
	uint32_t but;
	HWind    w;
	HIcon    i;
} Mouse;

typedef struct
{
	const char* name;
	int         x;
	int         y;
} MouseShape;

typedef struct
{
	CRect box;
	CSize s;
} CWindCvt;

int    XToScreen(int x, const CWindCvt* pcvt);
int    YToScreen(int y, const CWindCvt* pcvt);
CPoint PointToScreen(const CPoint* ppt, const CWindCvt* pcvt);
CRect  RectToScreen(const CRect* prct, const CWindCvt* pcvt);

int    XToWindow(int x, const CWindCvt* pcvt);
int    YToWindow(int y, const CWindCvt* pcvt);
CPoint PointToWindow(const CPoint* ppt, const CWindCvt* pcvt);
CRect  RectToWindow(const CRect* prct, const CWindCvt* pcvt);

void RoundX(int* x);
void RoundY(int* y);
void RoundPoint(CPoint* ppt);
void RoundUpSize(CSize* psize);
void RoundRect(CRect* prct);
void RoundUpRect(CRect* prct);
void RoundRectForPlot(CRect* prct);
bool IsPointInWimpRect(const CPoint* ppt, const CRect* prct);

#ifdef __cplusplus
}
#endif

#endif
