/******************************************************************************\
* "$RCSfile: GUI_Lib.hpp,v $"                                                  *
********************************************************************************
* Information by CVS or VSS:                                                   *
*     Last check in on: $Date: 2013-06-05 13:31:06 $                           *
*     by                $Author: schluckebier $
*     Revision        : $Revision: 1.27 $                                      *
*                                                                              *
* CVS: $Source: /Daten/Projekte/CVS/Lib/GUI_Lib/src/GUI_Lib.hpp,v $
********************************************************************************
* 08-Okt-2007                                                                  *
*******************************************************************************/
/*!	\file GUI_Lib.hpp
*	\brief GUI Library C++ Interface
*	\author (c) 2007 - 2013 IMAGO Technologies GmbH
*
*	$Revision: 1.27 $
*	$Date: 2013-06-05 13:31:06 $
*******************************************************************************/

#ifndef _GUI_LIB_HPP_
#define _GUI_LIB_HPP_

#include "GUI_Lib.h"

class CYImage;
class CCImage;
class CDialog;

/******************************************************************************/
/*! @brief Color Image class

	The CCImage class is a C++ interface for the #CIMAGE structure which
	simplifies the memory management.
*******************************************************************************/
class CCImage
{
friend class CYImage;
friend class CDialog;
friend class CDItem;
friend class CSItem;
public:
	unsigned char *m_pR; //!< Pointer to red image
	unsigned char *m_pG; //!< Pointer to green image
	unsigned char *m_pB; //!< Pointer to blue image

	//! \name Construction
	//! \{
	CCImage();
	CCImage(unsigned char *pRImage, unsigned char *pGImage, unsigned char *pBImage, int Width, int Height);
	CCImage(int Width, int Height);
	CCImage(CIMAGE *pImage);
	CCImage(int Device, const char *pFilename);
	CCImage(const void *pMem);
	~CCImage();
	void Alloc(unsigned char *pRImage, unsigned char *pGImage, unsigned char *pBImage, int Width, int Height);
	void Alloc(int Width, int Height);
	void Free();

	int GetWidth() const
		{ return m_Image.Width; }
	int GetHeight() const
		{ return m_Image.Height; }
	CIMAGE *GetCImage()
		{ return &m_Image; }
	//! \}

	//! \name Functions
	//! \{
	//--- Area ---
	int GetArea(const CCImage *pSrc, int x, int y, int Width, int Height)
		{ return GUI_GetArea(CheckImgPtr((CCImage*)pSrc), &m_Image, x, y, Width, Height); }
	int GetArea(const CCImage *pSrc, int x, int y)
		{ return GUI_GetArea(CheckImgPtr((CCImage*)pSrc), &m_Image, x, y, m_Image.Width, m_Image.Height); }
	int PutArea(CCImage *pDst, int x, int y)
		{ return GUI_PutArea(&m_Image, CheckImgPtr(pDst), x, y); }
	int CopyArea(CCImage *pDst, int SrcX, int SrcY,	int Width, int Height, int DstX, int DstY)
		{ return GUI_CopyArea(&m_Image, CheckImgPtr(pDst), SrcX, SrcY, Width, Height, DstX, DstY); }
	int CopyArea2Y(CYImage *pDst, int SrcX, int SrcY, int Width, int Height, int DstX, int DstY, char Mode);

	//--- ColorConvert ---
	int FromYUV(const void *pSrc, int Width, int Height)
		{ return GUI_YUV2CImage(pSrc, Width, Height, &m_Image); }
	int FromBayer(const void *pSrc, int Width, int Height, int Flag = 0)
		{ return GUI_Bayer2CImage(pSrc, Width, Height, &m_Image, Flag); }
	int FromBayerHQ(const void *pSrc, int Width, int Height, int Flag = 0)
		{ return GUI_Bayer2CImageHQ(pSrc, Width, Height, &m_Image, Flag); }
	int FromPackedRGB(const void *pSrc, int Width, int Height)
		{ return GUI_PackedRGB2CImage(pSrc, Width, Height, &m_Image); }
	int ToPackedRGB(void *pDst, int Width, int Height)
		{ return GUI_CImage2PackedRGB(&m_Image, pDst, Width, Height); }
	int ToPackedRGB32(void *pDst, int Width, int Height)
		{ return GUI_CImage2PackedRGB32(&m_Image, pDst, Width, Height); }

	//--- Image ---
	void Display(int x = 0, int y = 0)
		{ GUI_Display(&m_Image, x, y); }
	void DisplayArea(int DstX, int DstY, int SrcX, int SrcY, int Width, int Height)
		{ GUI_DisplayArea(&m_Image, DstX,  DstY, SrcX, SrcY, Width, Height); }
	void ToCYImage(CYImage *pImageY, char Mode);

	//--- Scale ---
	int Scale(CCImage *pDst, int Interpolation = 0)
		{ return GUI_ScaleImage(&m_Image, CheckImgPtr(pDst), Interpolation); }
	int ScaleArea(CCImage *pDst, int DstX, int DstY, int Width, int Height, int Interpolation = 0)
		{ return GUI_ScaleArea(&m_Image, CheckImgPtr(pDst), DstX, DstY, Width, Height, Interpolation); }
	int Zoom(CCImage *pDst, int VirtWidth, int VirtHeight, int VirtX, int VirtY, int Interpolation = 0)
		{ return GUI_ZoomImage(&m_Image, CheckImgPtr(pDst), VirtWidth, VirtHeight, VirtX, VirtY, Interpolation); }
	int ZoomArea(CCImage *pDst, int VirtWidth, int VirtHeight, int VirtX, int VirtY, int AreaWidth, int AreaHeight, int DstX, int DstY, int Interpolation = 0)
		{ return GUI_ZoomAreaBL(&m_Image, CheckImgPtr(pDst), VirtWidth, VirtHeight, VirtX, VirtY, AreaWidth, AreaHeight, DstX, DstY); }

	//--- Mirror ---
	int MirrorXA(CCImage *pDst)
		{ return GUI_MirrorXA(&m_Image, CheckImgPtr(pDst)); }
	int MirrorXA()
		{ return GUI_MirrorXA(&m_Image, &m_Image); }
	int MirrorYA(CCImage *pDst)
		{ return GUI_MirrorYA(&m_Image, CheckImgPtr(pDst)); }
	int MirrorYA()
		{ return GUI_MirrorYA(&m_Image, &m_Image); }
	int MirrorXYA(CCImage *pDst)
		{ return GUI_MirrorXYA(&m_Image, CheckImgPtr(pDst)); }
	int MirrorXYA()
		{ return GUI_MirrorXYA(&m_Image, &m_Image); }
	int Rotate90(CCImage *pDst, int Direction)
		{ return GUI_Rotate90(&m_Image, CheckImgPtr(pDst), Direction); }

	//--- Logo ---
	void DrawILogo(int x, int y, int Type)
		{ GUI_DrawILogo(&m_Image, x, y, Type); }

	//--- Shadow ---
	void Shadow(int x, int y, int Width, int Height)
		{ GUI_Shadow(&m_Image, x, y, Width, Height); }
	void Shadow(int x, int y, int Width, int Height, const COLOR *pCol)
		{ GUI_Shadow2(&m_Image, x, y, Width, Height, pCol); }
	void GradientV(int x, int y, int Width, int Height, const COLOR *pStart, const COLOR *pStop)
		{ GUI_GradientV(&m_Image, x, y, Width, Height, pStart, pStop); }
	void GradientH(int x, int y, int Width, int Height, const COLOR *pStart, const COLOR *pStop)
		{ GUI_GradientH(&m_Image, x, y, Width, Height, pStart, pStop); }
	//\}

	//! \name Text
	//! \{
	int TextOut(int Column, int Row, const char *pText)
		{ return GUI_TextOut(&m_Image, Row, Row, pText); }
	int TextOut(int Column, int Row, const char *pText, TEXTPARAMETER *pTP)
		{ return GUI_TextOutTP(&m_Image, Column, Row, pText, pTP); }
	void TextOutFormat(int Column, int Row, const char *pFormat, ...);
	void TextOutMark(int Column, int Row, const char *pText)
		{ GUI_TextOutMark(&m_Image, Column, Row, pText); }
	void TextOutMark(int Column, int Row, const char *pText, TEXTPARAMETER *pTP)
		{ GUI_TextOutMarkTP(&m_Image, Column, Row, pText, pTP); }
	int PutText(int x, int y, const char *pText, const FONT *pFont)
		{ return GUI_PutText(&m_Image, x, y, pText, pFont); }
	int PutText(int x, int y, const char *pText, const FONT *pFont, const TEXTPARAMETER *pTP)
		{ return GUI_PutTextTP(&m_Image, x, y, pText, pFont, pTP); }
	int FTPrint(int Column, int Row, const char *pText, const void *pFtFont)
		{ return GUI_FTPrint(&m_Image, Column, Row, pText, pFtFont); }
	int FTPrint(int Column, int Row, const char *pText, const void *pFtFont, TEXTPARAMETER *pTP)
		{ return GUI_FTPrintTP(&m_Image, Column, Row, pText, pFtFont, pTP); }
	//! \}

	//! \name Drawing
	//! \{
	//--- Circle ---
	void Circle(int xm, int ym, int r, const COLOR *pColor, int Flag = 0)
		{ GUI_CircleM(&m_Image, xm, ym, r, pColor, Flag); }
	void Circle(int xm, int ym, int r, int d, const COLOR *pColor, int Flag = 0)
		{ GUI_CircleM2(&m_Image, xm, ym, r, d, pColor, Flag); }
	void FCircle(int xm, int ym, int r, const COLOR *pColor)
		{ GUI_FCircleM(&m_Image, xm, ym, r, pColor); }

	//--- Cross ---
	void Cross(int xm, int ym, int Radius, const COLOR *pColor)
		{ GUI_Cross(&m_Image, xm, ym, Radius, pColor); }
	void Cross(int xm, int ym, int Radius, const COLOR *pColor, int Thickness, int Mode)
		{ GUI_Cross2(&m_Image, xm, ym, Radius, pColor, Thickness, Mode); }
	void ICross(int xm, int ym, int Radius)
		{ GUI_ICross(&m_Image, xm, ym, Radius); }

	//--- Rectangle ---
	void Rect(int x, int y, int Width, int Height, const COLOR *pColor)
		{ GUI_Rect(&m_Image, x, y, Width, Height, pColor); }
	void Rect(int x, int y, int Width, int Height, int w, const COLOR *pColor)
		{ GUI_Rect2(&m_Image, x, y, Width, Height, w, pColor); }
	void FRect(int x, int y, int Width, int Height, const COLOR *pColor)
		{ GUI_FRect(&m_Image, x, y, Width, Height, pColor); }
	void IRect(int x, int y, int Width, int Height)
		{ GUI_IRect(&m_Image, x, y, Width, Height); }
	void FIRect(int x, int y, int Width, int Height)
		{ GUI_FIRect(&m_Image, x, y, Width, Height); }
	void Border(int x, int y, int Width, int Height, int Style)
		{ GUI_Border(&m_Image, x, y, Width, Height, Style); }
	void Frame(int x, int y, int Width, int Height, const char *pText)
		{ GUI_Frame(&m_Image, x, y, Width, Height, pText); }
	void WndFrame(const char *pTitle)
		{ GUI_WndFrame(&m_Image, pTitle); }
	void WndFrame(const char *pTitle, const COLOR *pBackCol)
		{ GUI_WndFrame2(&m_Image, pTitle, pBackCol); }
	void WndFrame(const char *pTitle, const COLOR *pBackCol, COLOR GradCol[4])
		{ GUI_WndFrameG(&m_Image, pTitle, pBackCol, GradCol); }
	void Fill(const COLOR *pColor)
		{ GUI_FRect(&m_Image, 0, 0, m_Image.Width, m_Image.Height, pColor); }

	//--- Line ---
	void Line(int x1, int y1, int x2, int y2, const COLOR *pColor)
		{ GUI_Line(&m_Image, x1, y1, x2, y2, pColor); }
	void LineH(int x1, int y, int x2, const COLOR *pColor)
		{ GUI_LineH(&m_Image, x1, y, x2, pColor); }
	void LineV(int x, int y1, int y2, const COLOR *pColor)
		{ GUI_LineV(&m_Image, x, y1, y2, pColor); }
	void SetPoint(int x, int y, const COLOR *pColor)
		{ GUI_SetPoint(&m_Image, x, y, pColor); }
	COLOR GetPoint(int x, int y)
		{ return GUI_GetPoint(&m_Image, x, y); }

	//--- Draw ---
	void Line(int x1, int y1, int x2, int y2, const COLOR *pColor, int Thickness, int LineType = 1)
		{ GUI_Line2(&m_Image, x1, y1, x2, y2, pColor, Thickness, LineType); }
	void Rectangle(int x1, int y1, int x2, int y2, const COLOR *pColor, int Thickness = 1, int LineType = 1)
		{ GUI_Rectangle(&m_Image, x1, y1, x2, y2, pColor, Thickness, LineType); }
	void Circle(int x, int y, int Radius, const COLOR *pColor, int Thickness = 1, int LineType = 1)
		{ GUI_Circle(&m_Image, x, y, Radius, pColor, Thickness, LineType); }
	void Ellipse(int x, int y, int Width, int Height, int Angle, int StartAngle, int EndAngle,
		const COLOR *pColor, int Thickness = 1, int LineType = 1)
		{ GUI_Ellipse(&m_Image, x, y, Width, Height, Angle, StartAngle, EndAngle, pColor, Thickness, LineType); }
	void FillConvexPoly(const POINT *pPts, int nPts, const COLOR *pColor, int LineType = 1)
		{ GUI_FillConvexPoly(&m_Image, pPts, nPts, pColor, LineType); }
	void PolyLine(const POINT *pPts, int nPts, int Closed, const COLOR *pColor, int Thickness = 1, int LineType = 1)
		{ GUI_PolyLine(&m_Image, pPts, nPts, Closed, pColor, Thickness, LineType); }
	//! \}

	//! \name GUI
	//! \{
	//--- Button ---
	void Button(int x, int y, int Width, int Height, const char *pText, int Style)
		{ GUI_Button(&m_Image, x, y, Width, Height, pText, Style); }
	void Button(int x, int y, int Width, int Height, const char *pText, int Style, COLOR Col[4])
		{ GUI_ButtonG(&m_Image, x, y, Width, Height, pText, Style, Col); }
	void Button(int x, int y, int Width, int Height, const char *pText, int Style, COLOR Col[4], int Underscore, TEXTPARAMETER *pTP)
		{ GUI_ButtonEx(&m_Image, x, y, Width, Height, pText, Style, Col, Underscore, pTP); }
	void Button2(int x, int y, int Width, int Height, const char *pText, int Style)
		{ GUI_Button2(&m_Image, x, y, Width, Height, pText, Style); }
	void Button2(int x, int y, int Width, int Height, const char *pText, int Style, COLOR Col[4])
		{ GUI_ButtonG2(&m_Image, x, y, Width, Height, pText, Style, Col); }
	int  TextBox(int x, int y, int Width, const char *pText, int Style, int Filled)
		{ return GUI_TextBox(&m_Image, x, y, Width, pText, Style, Filled); }
	int  EditBox(int x, int y, int Width, char *pText, FILE *fKB, int Style, int Filled)
		{ return GUI_EditBox(&m_Image, x, y, Width, pText, fKB, Style, Filled); }
	int  EditBox2(int x, int y, int Width, char *pText, FILE *fKB, int Style, int Filled)
		{ return GUI_EditBox2(&m_Image, x, y, Width, pText, fKB, Style, Filled); }
	void DrawEditBox(int x, int y, int Width, const char *pText, int Style, int Filled, int Cursor)
		{ GUI_DrawEditBox(&m_Image, x, y, Width, pText, Style, Filled, Cursor); }
	void CheckMark(int x, int y, int Width, int Height, int Checked)
		{ GUI_CheckMark(&m_Image, x, y, Width, Height, Checked); }
	void CheckBox(int x, int y, int Width, const char *pText, int Style, int Checked)
		{ GUI_CheckBox(&m_Image, x, y, Width, pText, Style, Checked); }
	void CheckBox(int x, int y, int Width, int Height, const char *pText, int Style, int Checked)
		{ GUI_CheckBox2(&m_Image, x, y, Width, Height, pText, Style, Checked); }
	void CheckBox(int x, int y, int Width, int Height, const char *pText, int Style, int Checked, COLOR Col[4])
		{ GUI_CheckBoxG(&m_Image, x, y, Width, Height, pText, Style, Checked, Col); }
	void Icon(int x, int y, const CCImage *pIcon, int Style)
		{ GUI_Icon(&m_Image, x, y, CheckImgPtr((CCImage*)pIcon), Style); }

	//--- DirBox ---
	int DirBox(int Device, int x, int y, int Width, int Height, char FileName[], FILE *fKB)
		{ return GUI_DirBox(&m_Image, Device, x, y, Width, Height, FileName, fKB); }
	int DirBox(int Device, int x, int y, int Width, int Height, FILE *fKB, unsigned char Flags, FILEINFO *pFInfo)
		{ return GUI_DirBoxEx(&m_Image, Device, x, y, Width, Height, fKB, Flags, pFInfo); }

	//--- Editor ---
	int Editor(const char *cTitle, int x, int y, int Width, int Height, int MaxBuffer, char *pText, FILE *fKB, int *pFileLength, int *pExitKey)
		{ return GUI_Editor(&m_Image, cTitle, x, y, Width, Height, MaxBuffer, pText, fKB, pFileLength, pExitKey); }

	//--- MessageBox ---
	int MessageBox(const char *pText, FILE *fKB = NULL, int Type = GUI_MBOK)
		{ return GUI_MessageBox(&m_Image, pText, fKB, Type); }
	int MessageBox(FILE *fKB, int Type, const char *pFormat, ...);
	int MessageBox(FILE *fKB, const char *pText, const char *pTitle, const char *pButton1, const char *pButton2 = NULL, const char *pButton3 = NULL)
		{ return GUI_MessageBoxEx(&m_Image, fKB, pText, pTitle, pButton1, pButton2, pButton3); }
	int ValueBox(const char *pLabel, const char *pTitle, int *pValue, int Min, int Max, FILE *fKB)
		{ return GUI_ValueBox(&m_Image, pLabel, pTitle, pValue, Min, Max, fKB); }
	int StringBox(const char *pLabel, const char *pTitle, char *pString, int MaxLen, FILE *fKB)
		{ return GUI_StringBox(&m_Image, pLabel, pTitle, pString, MaxLen, fKB); }
	int OpenFileBox(int Device, const char *pTitle, char *pFilename, const char *pFilter, FILE *fKB)
		{ return GUI_OpenFileBox(Device, &m_Image, pTitle, pFilename, pFilter, fKB); }
	int SaveFileBox(int Device, const char *pTitle, char *pFilename, const char *pFilter, FILE *fKB)
		{ return GUI_SaveFileBox(Device, &m_Image, pTitle, pFilename, pFilter, fKB); }
	int SelDirBox(int Device, const char *pTitle, char *pPath, FILE *fKB)
		{ return GUI_SelDirBox(Device, &m_Image, pTitle, pPath, fKB); }

	//--- SelectBox ---
	int SelectBox(int x, int y, int Width, int Height, const char *pText, FILE *fKB, int Select)
		{ return GUI_SelectBox(&m_Image, x, y, Width, Height, pText, fKB, Select); }
	int SelectBox(int x, int y, int Width, int Height, int SelectType, const char *pText, FILE *fKB, int *pSelect, int *pKey, int *pScrolled)
		{ return GUI_SelectBoxEx(&m_Image, x, y, Width, Height, SelectType, pText, fKB, pSelect, pKey, pScrolled); }
	int ListBox(int x, int y, int Width, int Height, char *pText[], int Elements, FILE *fKB, int Select)
		{ return GUI_ListBox(&m_Image, x, y, Width, Height, pText, Elements, fKB, Select); }
	int ListBox(int x, int y, int Width, int Height, int SelectType, char *pText[], int Elements, FILE *fKB, int *pSelect, int *pKey, int *pScrolled)
		{ return GUI_ListBoxEx(&m_Image, x, y, Width, Height, SelectType, pText, Elements, fKB, pSelect, pKey, pScrolled); }

	//--- Slider ---
	void Slider(int x, int y, int Width, int Height, int Pos, const TEXTPARAMETER *pTP=NULL)
		{ return GUI_DrawSliderTP(&m_Image, x, y, Width, Height, Pos, pTP); }
	int  EditSlider(int x, int y, int Width, const char *pText, int *pValue, int nMin, int nMax, FILE *fKB)
		{ return GUI_EditSlider(&m_Image, x, y, Width, pText, pValue, nMin, nMax, fKB); }
	void DrawEditSlider(int x, int y, int Width, const char *pText, int Value, int nMin, int nMax, int Active, int Logarithmic, TEXTPARAMETER *pTP=NULL)
		{ GUI_DrawEditSliderTP(&m_Image, x, y, Width, pText, Value, nMin, nMax, Active, Logarithmic, pTP); }
	void Progress(int x, int y, int Width, int Height, int Pos, int Style)
		{ GUI_Progress(&m_Image, x, y, Width, Height, Pos, Style); }
	//! \}

	//! \name BMP
	//! \{
	int ReadBMP(int Device, const char *pFilename)
		{ return GUI_ReadCImage(Device, pFilename, &m_Image); }
	int ReadBMP(const void *pMem)
		{ return GUI_ReadCImageMem(pMem, &m_Image); }
	int WriteBMP(int Device, const char *pFilename)
		{ return GUI_WriteCImage(Device, pFilename, &m_Image); }
	int WriteBMP(void *pMem)
		{ return GUI_WriteCImageMem(pMem, &m_Image); }
	//\}

#ifdef _JPEG_LIB_HID // #include "JPEG_Lib.h"
	//! \name JPEG
	//! \{
	int ReadJPG(int Device, const char *pFilename)
		{ return JPEG_ReadCImage(Device, pFilename, &m_Image); }
	int ReadJPG(const void *pMem)
		{ return JPEG_ReadCImageMem(pMem, &m_Image); }
	int WriteJPG(int Device, const char *pFilename)
		{ return JPEG_WriteCImage(Device, pFilename, &m_Image); }
	int WriteJPG(void *pMem)
		{ return JPEG_WriteCImageMem(pMem, &m_Image); }
	//! \}
#endif

#ifdef _PNG_LIB_HID // #include "PNG_Lib.h"
	//! \name PNG
	//! \{
	int ReadPNG(int Device, const char *pFilename)
		{ return PNG_ReadCImage(Device, pFilename, &m_Image); }
	int ReadPNG(const void *pMem)
		{ return PNG_ReadCImageMem(pMem, &m_Image); }
	int WritePNG(int Device, const char *pFilename)
		{ return PNG_WriteCImage(Device, pFilename, &m_Image); }
	int WritePNG(void *pMem)
		{ return PNG_WriteCImageMem(pMem, &m_Image); }
	//! \}
#endif

#ifdef _JP2_LIB_HID // #include "OpenJPEG_Lib.h"
	//! \name JPEG 2000
	//! \{
	int ReadJP2(int Device, const char *pFilename)
		{ return JP2_ReadCImage(Device, pFilename, &m_Image); }
	int ReadJP2(const void *pMem, int MemSize)
		{ return JP2_ReadCImageMem(pMem, &m_Image, MemSize); }
	int WriteJP2(int Device, const char *pFilename)
		{ return JP2_WriteCImage(Device, pFilename, &m_Image); }
	int WriteJP2(void *pMem)
		{ return JP2_WriteCImageMem(pMem, &m_Image); }
	//! \}
#endif

private:
	//! Checks for valid image pointer.
	static CIMAGE *CheckImgPtr(CCImage *pImage)
		{ if (pImage == NULL) return NULL; else return &pImage->m_Image; }

	CIMAGE m_Image;	//!< Color image
	int m_Alloc;	//!< Allocation state
};

/******************************************************************************/
/*! @brief Gray Image class

	C++ interface for the #YIMAGE structure.
*******************************************************************************/
class CYImage
{
friend class CCImage;
public:
	unsigned char *m_pY; //!< Pointer to gray image

	//! \name Construction
	//! \{
	CYImage();
	CYImage(unsigned char *pYImage, int Width, int Height);
	CYImage(int Width, int Height);
	CYImage(YIMAGE *pImage);
	CYImage(int Device, const char *pFilename);
	CYImage(const void *pMem);
	~CYImage();
	void Alloc(unsigned char *pYImage, int Width, int Height);
	void Free();
	//! \}

	//! \name Functions
	//! \{
	int GetWidth() const
		{ return m_Image.Width; }
	int GetHeight() const
		{ return m_Image. Height; }
	YIMAGE *GetYImage()
		{ return &m_Image; }

	//--- Area ---
	int GetArea(const CYImage *pSrc, int x, int y, int Width, int Height)
		{ return GUI_GetYArea(CheckImgPtr((CYImage*)pSrc), &m_Image, x, y, Width, Height); }
	int GetArea(const CYImage *pSrc, int x, int y)
		{ return GUI_GetYArea(CheckImgPtr((CYImage*)pSrc), &m_Image, x, y, m_Image.Width, m_Image.Height); }
	int PutArea(CYImage *pDst, int x, int y)
		{ return GUI_PutYArea(&m_Image, CheckImgPtr(pDst), x, y); }
	int CopyArea(CYImage *pDst, int SrcX, int SrcY, int Width, int Height, int DstX, int DstY)
		{ return GUI_CopyYArea(&m_Image, CheckImgPtr(pDst), SrcX, SrcY, Width, Height, DstX, DstY); }
	int CopyArea2C(CCImage *pDst, int SrcX, int SrcY, int Width, int Height, int DstX, int DstY)
		{ return GUI_CopyYArea2RGB(&m_Image, CCImage::CheckImgPtr(pDst), SrcX, SrcY, Width, Height, DstX, DstY); }

	//--- ColorConvert ---
	int FromYUV(const void *pSrc, int Width, int Height)
		{ return GUI_YUV2YImage(pSrc, Width, Height, &m_Image); }
	int FromBayer(const void *pSrc, int Width, int Height, int Flag = 0)
		{ return GUI_Bayer2YImage(pSrc, Width, Height, &m_Image, Flag); }
	int FromY(const void *pSrc, int Width, int Height)
		{ return GUI_Y2YImage(pSrc, Width, Height, &m_Image); }
	void ToCCImage(CCImage *pImageC, char Mode)
		{ GUI_YImage2CImage(&m_Image, CCImage::CheckImgPtr(pImageC), Mode); }

	//--- Image ---
	void Display(int x = 0, int y = 0)
		{ GUI_DisplayY(&m_Image, x, y); }
	void DisplayArea(int DstX, int DstY, int SrcX, int SrcY, int Width, int Height)
		{ GUI_DisplayAreaY(&m_Image, DstX,  DstY, SrcX, SrcY, Width, Height); }

	//---Scale ---
	int Scale(CYImage *pDst, int Interpolation = 0)
		{ return GUI_ScaleImageY(&m_Image, CheckImgPtr(pDst), Interpolation); }
	int ScaleArea(CYImage *pDst, int DstX, int DstY, int Width, int Height, int Interpolation = 0)
		{ return GUI_ScaleAreaY(&m_Image, CheckImgPtr(pDst), DstX, DstY, Width, Height, Interpolation); }
//	int Zoom(CYImage *pDst, int VirtWidth, int VirtHeight, int VirtX, int VirtY, int Interpolation)
//		{ return GUI_ZoomImageY(&m_Image, CheckImgPtr(pDst), VirtWidth, VirtHeight, VirtX, VirtY, Interpolation); }
//	int ZoomArea(CYImage *pDst, int VirtWidth, int VirtHeight, int VirtX, int VirtY, int AreaWidth, int AreaHeight, int DstX, int DstY)
//		{ return GUI_ZoomAreaBLY(&m_Image, CheckImgPtr(pDst), VirtWidth, VirtHeight, VirtX, VirtY, AreaWidth, AreaHeight, DstX, DstY); }

	//--- Mirror ---
	int MirrorXA(CYImage *pDst)
		{ return GUI_MirrorXAY(&m_Image, CheckImgPtr(pDst)); }
	int MirrorXA()
		{ return GUI_MirrorXAY(&m_Image, &m_Image); }
	int MirrorYA(CYImage *pDst)
		{ return GUI_MirrorYAY(&m_Image, CheckImgPtr(pDst)); }
	int MirrorYA()
		{ return GUI_MirrorYAY(&m_Image, &m_Image); }
	int MirrorXYA(CYImage *pDst)
		{ return GUI_MirrorXYAY(&m_Image, CheckImgPtr(pDst)); }
	int MirrorXYA()
		{ return GUI_MirrorXYAY(&m_Image, &m_Image); }
	int Rotate90(CYImage *pDst, int Direction)
		{ return GUI_Rotate90Y(&m_Image, CheckImgPtr(pDst), Direction); }

	//--- Logo ---
	void DrawILogo(int x, int y, int Type)
		{ GUI_DrawILogoY(&m_Image, x, y, Type); }

	//--- Shadow ---
	void Shadow(int x, int y, int Width, int Height)
		{ GUI_ShadowY(&m_Image, x, y, Width, Height); }
	void Shadow(int x, int y, int Width, int Height, unsigned char Color)
		{ GUI_Shadow2Y(&m_Image, x, y, Width, Height, Color); }
	void GradientV(int x, int y, int Width, int Height, unsigned char Start, unsigned char Stop)
		{ GUI_GradientVY(&m_Image, x, y, Width, Height, Start, Stop); }
	void GradientH(int x, int y, int Width, int Height, unsigned char Start, unsigned char Stop)
		{ GUI_GradientHY(&m_Image, x, y, Width, Height, Start, Stop); }
	//! \}

	//! \name Text
	//! \{
	int TextOut(int col, int line, const char *pText)
		{ return GUI_TextOutY(&m_Image, col, line, pText); }
	int TextOut(int col, int line, const char *pText, TEXTPARAMETER *pTP)
		{ return GUI_TextOutTPY(&m_Image, col, line, pText, pTP); }
	void TextOutFormat(int col, int line, const char *pFormat, ...);
	void TextOutMark(int col, int line, const char *pText)
		{ GUI_TextOutMarkY(&m_Image, col, line, pText); }
	void TextOutMark(int col, int line, const char *pText, TEXTPARAMETER *pTP)
		{ GUI_TextOutMarkTPY(&m_Image, col, line, pText, pTP); }
	int PutText(int x, int y, const char *pText, const FONT *pFont)
		{ return GUI_PutTextY(&m_Image, x, y, pText, pFont); }
	int PutText(int x, int y, const char *pText, const FONT *pFont, const TEXTPARAMETER *pTP)
		{ return GUI_PutTextTPY(&m_Image, x, y, pText, pFont, pTP); }
	int FTPrint(int col, int line, const char *pText, const void *pFtFont)
		{ return GUI_FTPrintY(&m_Image, col, line, pText, pFtFont); }
	int FTPrint(int col, int line, const char *pText, const void *pFtFont, TEXTPARAMETER *pTP)
		{ return GUI_FTPrintTPY(&m_Image, col, line, pText, pFtFont, pTP); }
	//! \}

	//! \name Drawing
	//! \{
	//--- Circle ---
	void Circle(int xm, int ym, int r, unsigned char Color, int Flag = 0)
		{ GUI_CircleMY(&m_Image, xm, ym, r, Color, Flag); }
	void Circle(int xm, int ym, int r, int d, unsigned char Color, int Flag = 0)
		{ GUI_CircleM2Y(&m_Image, xm, ym, r, d, Color, Flag); }
	void FCircle(int xm, int ym, int r, unsigned char Color)
		{ GUI_FCircleMY(&m_Image, xm, ym, r, Color); }

	//--- Cross ---
	void Cross(int xm, int ym, int Radius, unsigned char Color)
		{ GUI_CrossY(&m_Image, xm, ym, Radius, Color); }
	void Cross(int xm, int ym, int Radius, unsigned char Color, int Thickness, int Mode)
		{ GUI_Cross2Y(&m_Image, xm, ym, Radius, Color, Thickness, Mode); }
	void ICross(int xm, int ym, int Radius)
		{ GUI_ICrossY(&m_Image, xm, ym, Radius); }

	//--- Line ---
	void Line(int x1, int y1, int x2, int y2, unsigned char Color)
		{ GUI_LineY(&m_Image, x1, y1, x2, y2, Color); }
	void LineH(int x1, int y, int x2, unsigned char Color)
		{ GUI_LineHY(&m_Image, x1, y, x2, Color); }
	void LineV(int x, int y1, int y2, unsigned char Color)
		{ GUI_LineVY(&m_Image, x, y1, y2, Color); }
	void SetPoint(int x, int y, unsigned char Color)
		{ GUI_SetPointY(&m_Image, x, y, Color); }
	unsigned char GetPoint(int x, int y)
		{ return GUI_GetPointY(&m_Image, x, y); }

	//--- Rectangle ---
	void Rect(int x, int y, int Width, int Height, unsigned char Color)
		{ GUI_RectY(&m_Image, x, y, Width, Height, Color); }
	void Rect(int x, int y, int Width, int Height, int w, unsigned char Color)
		{ GUI_Rect2Y(&m_Image, x, y, Width, Height, w, Color); }
	void FRect(int x, int y, int Width, int Height, unsigned char Color)
		{ GUI_FRectY(&m_Image, x, y, Width, Height, Color); }
	void IRect(int x, int y, int Width, int Height)
		{ GUI_IRectY(&m_Image, x, y, Width, Height); }
	void FIRect(int x, int y, int Width, int Height)
		{ GUI_FIRectY(&m_Image, x, y, Width, Height); }
	void Border(int x, int y, int Width, int Height, int Style)
		{ GUI_BorderY(&m_Image, x, y, Width, Height, Style); }
	void Frame(int x, int y, int Width, int Height, const char *pText)
		{ GUI_FrameY(&m_Image, x, y, Width, Height, pText); }
	void WndFrame(const char *pTitle)
		{ GUI_WndFrameY(&m_Image, pTitle); }
	void WndFrame(const char *pTitle, unsigned char BackCol)
		{ GUI_WndFrame2Y(&m_Image, pTitle, BackCol); }
	void WndFrame(const char *pTitle, unsigned char BackCol, unsigned char GradCol[4])
		{ GUI_WndFrameGY(&m_Image, pTitle, BackCol, GradCol); }
	void Fill(unsigned char Color)
		{ GUI_FRectY(&m_Image, 0, 0, m_Image.Width, m_Image.Height, Color); }

	//--- Draw ---
	void Line(int x1, int y1, int x2, int y2, unsigned char Color, int Thickness, int LineType = 1)
		{ GUI_Line2Y(&m_Image, x1, y1, x2, y2, Color, Thickness, LineType); }
	void Rectangle(int x1, int y1, int x2, int y2, unsigned char Color, int Thickness = 1, int LineType = 1)
		{ GUI_RectangleY(&m_Image, x1, y1, x2, y2, Color, Thickness, LineType); }
	void Circle(int x, int y, int Radius, unsigned char Color, int Thickness = 1, int LineType = 1)
		{ GUI_CircleY(&m_Image, x, y, Radius, Color, Thickness, LineType); }
	void Ellipse(int x, int y, int Width, int Height, int Angle, int StartAngle, int EndAngle,
		unsigned char Color, int Thickness = 1, int LineType = 1)
		{ GUI_EllipseY(&m_Image, x, y, Width, Height, Angle, StartAngle, EndAngle, Color, Thickness, LineType); }
	void FillConvexPoly(const POINT *pPts, int nPts, unsigned char Color, int LineType = 1)
		{ GUI_FillConvexPolyY(&m_Image, pPts, nPts, Color, LineType); }
	void PolyLine(const POINT *pPts, int nPts, int Closed, unsigned char Color, int Thickness = 1, int LineType = 1)
		{ GUI_PolyLineY(&m_Image, pPts, nPts, Closed, Color, Thickness, LineType); }
	//! \}

	//! \name GUI
	//! \{
	//--- Button ---
	void Button(int x, int y, int Width, int Height, const char *pText, int Style)
		{ GUI_ButtonY(&m_Image, x, y, Width, Height, pText, Style); }
	void Button(int x, int y, int Width, int Height, const char *pText, int Style, unsigned char Col[4])
		{ GUI_ButtonGY(&m_Image, x, y, Width, Height, pText, Style, Col); }
	void Button(int x, int y, int Width, int Height, const char *pText, int Style, unsigned char Col[4], int Underscore, TEXTPARAMETER *pTP)
		{ GUI_ButtonExY(&m_Image, x, y, Width, Height, pText, Style, Col, Underscore, pTP); }
	void Button2(int x, int y, int Width, int Height, const char *pText, int Style)
		{ GUI_Button2Y(&m_Image, x, y, Width, Height, pText, Style); }
	void Button2(int x, int y, int Width, int Height, const char *pText, int Style, unsigned char Col[4])
		{ GUI_ButtonG2Y(&m_Image, x, y, Width, Height, pText, Style, Col); }
	int  TextBox(int x, int y, int Width, const char *pText, int Style, int Filled)
		{ return GUI_TextBoxY(&m_Image, x, y, Width, pText, Style, Filled); }
	int  EditBox(int x, int y, int Width, char *pText, FILE *fKB, int Style, int Filled)
		{ return GUI_EditBoxY(&m_Image, x, y, Width, pText, fKB, Style, Filled); }
	int  EditBox2(int x, int y, int Width, char *pText, FILE *fKB, int Style, int Filled)
		{ return GUI_EditBox2Y(&m_Image, x, y, Width, pText, fKB, Style, Filled); }
	void DrawEditBox(int x, int y, int Width, const char *pText, int Style, int Filled, int Cursor)
		{ GUI_DrawEditBoxY(&m_Image, x, y, Width, pText, Style, Filled, Cursor); }
	void CheckMark(int x, int y, int Width, int Height, int Checked)
		{ GUI_CheckMarkY(&m_Image, x, y, Width, Height, Checked); }
	void CheckBox(int x, int y, int Width, const char *pText, int Style, int Checked)
		{ GUI_CheckBoxY(&m_Image, x, y, Width, pText, Style, Checked); }
	void CheckBox(int x, int y, int Width, int Height, const char *pText, int Style, int Checked)
		{ GUI_CheckBox2Y(&m_Image, x, y, Width, Height, pText, Style, Checked); }
	void CheckBox(int x, int y, int Width, int Height, const char *pText, int Style, int Checked, unsigned char Col[4])
		{ GUI_CheckBoxGY(&m_Image, x, y, Width, Height, pText, Style, Checked, Col); }
	void Icon(int x, int y, const CYImage *pIcon, int Style)
		{ GUI_IconY(&m_Image, x, y, CheckImgPtr((CYImage*)pIcon), Style); }

	//--- DirBox ---
	int DirBox(int Device, int x, int y, int Width, int Height, char FileName[], FILE *fKB)
		{ return GUI_DirBoxY(&m_Image, Device, x, y, Width, Height, FileName, fKB); }
	int DirBox(int Device, int x, int y, int Width, int Height, FILE *fKB, unsigned char Flags, FILEINFO *pFInfo)
		{ return GUI_DirBoxExY(&m_Image, Device, x, y, Width, Height, fKB, Flags, pFInfo); }

	//--- Editor ---
	int Editor(const char *cTitle, int x, int y, int Width, int Height, int MaxBuffer, char *pText, FILE *fKB, int *pFileLength, int *pExitKey)
		{ return GUI_EditorY(&m_Image, cTitle, x, y, Width, Height, MaxBuffer, pText, fKB, pFileLength, pExitKey); }

	//--- MessageBox ---
	int MessageBox(const char *pText, FILE *fKB = NULL, int Type = GUI_MBOK)
		{ return GUI_MessageBoxY(&m_Image, pText, fKB, Type); }
	int MessageBox(FILE *fKB, int Type, const char *pFormat, ...);

	//--- SelectBox ---
	int SelectBox(int x, int y, int Width, int Height, const char *pText, FILE *fKB, int Select)
		{ return GUI_SelectBoxY(&m_Image, x, y, Width, Height, pText, fKB, Select); }
//	int SelectBox(int x, int y, int Width, int Height, int SelectType, const char *pText, FILE *fKB, int *pSelect, int *pKey, int *pScrolled)
//		{ return GUI_SelectBoxExY(&m_Image, x, y, Width, Height, SelectType, pText, fKB, pSelect, pKey, pScrolled); }

	//--- Slider ---
	void Slider(int x, int y, int Width, int Height, int Pos)
		{ return GUI_SliderY(&m_Image, x, y, Width, Height, Pos); }
	int  EditSlider(int x, int y, int Width, const char *pText, int *pValue, int nMin, int nMax, FILE *fKB)
		{return GUI_EditSliderY(&m_Image, x, y, Width, pText, pValue, nMin, nMax, fKB); }
	void Progress(int x, int y, int Width, int Height, int Pos, int Style)
		{ GUI_ProgressY(&m_Image, x, y, Width, Height, Pos, Style); }
	//! \}

	//! \name BMP
	//! \{
	int ReadBMP(int Device, const char *pFilename)
		{ return GUI_ReadYImage(Device, pFilename, &m_Image); }
	int ReadBMP(const void *pMem)
		{ return GUI_ReadYImageMem(pMem, &m_Image); }
	int WriteBMP(int Device, const char *pFilename)
		{ return GUI_WriteYImage(Device, pFilename, &m_Image); }
	int WriteBMP(void *pMem)
		{ return GUI_WriteYImageMem(pMem, &m_Image); }
	//! \}

#ifdef _JPEG_LIB_HID
	//! \name JPEG
	//! \{
	int ReadJPG(int Device, const char *pFilename)
		{ return JPEG_ReadYImage(Device, pFilename, &m_Image); }
	int ReadJPG(const void *pMem)
		{ return JPEG_ReadYImageMem(pMem, &m_Image); }
	int WriteJPG(void *pMem)
		{ return JPEG_WriteYImageMem(pMem, &m_Image); }
	int WriteJPG(int Device, const char *pFilename)
		{ return JPEG_WriteYImage(Device, pFilename, &m_Image); }
	//! \}
#endif

#ifdef _PNG_LIB_HID
	//! \name PNG
	//! \{
	int ReadPNG(int Device, const char *pFilename)
		{ return PNG_ReadYImage(Device, pFilename, &m_Image); }
	int ReadPNG(const void *pMem)
		{ return PNG_ReadYImageMem(pMem, &m_Image); }
	int WritePNG(int Device, const char *pFilename)
		{ return PNG_WriteYImage(Device, pFilename, &m_Image); }
	int WritePNG(void *pMem)
		{ return PNG_WriteYImageMem(pMem, &m_Image); }
	//! \}
#endif

#ifdef _JP2_LIB_HID
	//! \name JPEG 2000
	//! \{
	int ReadJP2(int Device, const char *pFilename)
		{ return JP2_ReadYImage(Device, pFilename, &m_Image); }
	int ReadJP2(const void *pMem, int MemSize)
		{ return JP2_ReadYImageMem(pMem, &m_Image, MemSize); }
	int WriteJP2(int Device, const char *pFilename)
		{ return JP2_WriteYImage(Device, pFilename, &m_Image); }
	int WriteJP2(void *pMem)
		{ return JP2_WriteYImageMem(pMem, &m_Image); }
	//! \}
#endif

private:
	//! Checks for valid image pointer.
	static YIMAGE *CheckImgPtr(CYImage *pImage)
		{ if (pImage == NULL) return NULL; else return &pImage->m_Image; }

	YIMAGE m_Image;	//!< Gray image
	int m_Alloc;	//!< Allocation state
};

/******************************************************************************/
/*! @brief Dialog class

	C++ interface for using dialog boxes.\n
	See \ref Dialog for more information.\n
	See \ref xdialogc for example.
*******************************************************************************/
class CDialog
{
public:
	//! \name Construction
	//! \{
	CDialog();
	CDialog(int Width, int Height, const char *pTitle=NULL)
		{ m_Dialog = GUI_DlgCreate(Width, Height, pTitle); }
	~CDialog()
		{ GUI_DlgFree(&m_Dialog); }
	void Create(int Width, int Height, const char *pTitle=NULL)
		{ m_Dialog = GUI_DlgCreate(Width, Height, pTitle); }
	void Free();
	//! \}

	//! \name Creation
	//! \{
	DLG_ITEMS *AddText(int x, int y, const char *pLabel)
		{ return GUI_DlgAddText(&m_Dialog, x, y, pLabel); }
	DLG_ITEMS *AddLabel(int x, int y, const char *pLabel, int Id)
		{ return GUI_DlgAddLabel(&m_Dialog, x, y, pLabel, Id); }
	DLG_ITEMS *AddBorder(int x, int y, int Width, int Height, int Style)
		{ return GUI_DlgAddBorder(&m_Dialog, x, y, Width, Height, Style); }
	DLG_ITEMS *AddIcon(int x, int y, CCImage *pIcon)
		{ return GUI_DlgAddIcon(&m_Dialog, x, y, &pIcon->m_Image); }
	DLG_ITEMS *AddAnimIcon(int x, int y, CCImage *pIconList, int NumIcons);
	DLG_ITEMS *AddDynamicText(int x, int y, char *pString)
		{ return GUI_DlgAddDynamicText(&m_Dialog, x, y, pString); }
	DLG_ITEMS *AddTextBox(int x, int y, int Width, int Height, const char *pString, int Style)
		{ return GUI_DlgAddTextBox(&m_Dialog, x, y, Width, Height, pString, Style); }
	DLG_ITEMS *AddStaticButton(int x, int y, int Width, int Height, const char *pString, int Style)
		{ return GUI_DlgAddStaticButton(&m_Dialog, x, y, Width, Height, pString, Style); }
	DLG_ITEMS *AddStaticButton(int x, int y, int Width, int Height, const char *pString, int Style, COLOR Col[4])
		{ return GUI_DlgAddStaticGButton(&m_Dialog, x, y, Width, Height, pString, Style, Col); }
	DLG_ITEMS *AddProgress(int x, int y, int Width, int Height, int *pPos, int Style)
		{ return GUI_DlgAddProgress(&m_Dialog, x, y, Width, Height, pPos, Style); }
	DLG_ITEMS *AddCheckMark(int x, int y, int Width, int Height, const char *pLabel, int *pState)
		{ return GUI_DlgAddCheckMark(&m_Dialog, x, y, Width, Height, pLabel, pState); }
	DLG_ITEMS *AddFrame(int x, int y, int Width, int Height, const char *pLabel)
		{ return GUI_DlgAddFrame(&m_Dialog, x, y, Width, Height, pLabel); }

	DLG_ITEMD *AddButton(int x, int y, int Width, int Height, const char *pLabel, int Id)
		{ return GUI_DlgAddButton(&m_Dialog, x, y, Width, Height, pLabel, Id); }
	DLG_ITEMD *AddButton(int x, int y, int Width, int Height, const char *pLabel, COLOR Col[4], int Id)
		{ return GUI_DlgAddGButton(&m_Dialog, x, y, Width, Height, pLabel, Col, Id); }
	DLG_ITEMD *AddIconButton(int x, int y, int Width, int Height, const char *pLabel, CCImage *pIcon, int Id)
		{ return GUI_DlgAddIconButton(&m_Dialog, x, y, Width, Height, pLabel, &pIcon->m_Image, Id); }
	DLG_ITEMD *AddAnimButton(int x, int y, int Width, int Height, const char *pLabel, CCImage *pIconList, int NumIcons, int Id);
	DLG_ITEMD *AddCBButton(int x, int y, int Width, int Height, const char *pLabel, GUI_FxnCallback Fxn, void *pData, int Id)
		{ return GUI_DlgAddCBButton(&m_Dialog, x, y, Width, Height, pLabel, Fxn, pData, Id); }
	DLG_ITEMD *AddCheckBox(int x, int y, int Width, const char *pLabel, int *pState, int Id)
		{ return GUI_DlgAddCheckBox(&m_Dialog, x, y, Width, pLabel, pState, Id); }
	DLG_ITEMD *AddCheckBox(int x, int y, int Width, int Height, const char *pLabel, int *pState, int Id)
		{ return GUI_DlgAddCheckBox2(&m_Dialog, x, y, Width, Height, pLabel, pState, Id); }
	DLG_ITEMD *AddCheckBox(int x, int y, int Width, int Height, const char *pLabel, int *pState, COLOR Col[4], int Id)
		{ return GUI_DlgAddGCheckBox(&m_Dialog, x, y, Width, Height, pLabel, pState, Col, Id); }
	DLG_ITEMD *AddSEditBox(int x, int y, int Width, char *pString, int Id)
		{ return GUI_DlgAddSEditBox(&m_Dialog, x, y, Width, pString, Id); }
	DLG_ITEMD *AddSEditBox2(int x, int y, int Width, char *pString, int Id)
		{ return GUI_DlgAddSEditBox2(&m_Dialog, x, y, Width, pString, Id); }
	DLG_ITEMD *AddVEditBox(int x, int y, int Width, int *pValue, int Min, int Max, int Id)
		{ return GUI_DlgAddVEditBox(&m_Dialog, x, y, Width, pValue, Min, Max, Id); }
	DLG_ITEMD *AddVSpinBox(int x, int y, int Width, int *pValue, int Min, int Max, int Id)
		{ return GUI_DlgAddVSpinBox(&m_Dialog, x, y, Width, pValue, Min, Max, Id); }
	DLG_ITEMD *AddSlider(int x, int y, int Width, int Height, int *pPos, int Min, int Max, int Id)
		{ return GUI_DlgAddSlider(&m_Dialog, x, y, Width, Height, pPos, Min, Max, Id); }
	DLG_ITEMD *AddEditSlider(int x, int y, int Width, const char *pLabel, int *pPos, int Min, int Max, int Id)
		{ return GUI_DlgAddEditSlider(&m_Dialog, x, y, Width, pLabel, pPos, Min, Max, Id); }
	DLG_ITEMD *AddSelectBox(int x, int y, int Width, int Height, char *pText, int *pSelect, int Id)
		{ return GUI_DlgAddSelectBox(&m_Dialog, x, y, Width, Height, pText, pSelect, Id); }
	DLG_ITEMD *AddFileSelectBox(int x, int y, int Width, int Height, int Device, char *pFilename, int Flags, const char *pFilter, int Id)
		{ return GUI_DlgAddFileSelectBox(&m_Dialog, x, y, Width, Height, Device, pFilename, Flags, pFilter, Id); }
	DLG_ITEMD *AddListBox(int x, int y, int Width, int Height, char *pText[], int Elements, int *pSelect, int Id)
		{ return GUI_DlgAddListBox(&m_Dialog, x, y, Width, Height, pText, Elements, pSelect, Id); }
	DLG_ITEMD *AddChoiceBox(int x, int y, int Width, int Height, char *pText, int Style, int *pSelect, int Id)
		{ return GUI_DlgAddChoiceBox(&m_Dialog, x, y, Width, Height, pText, Style, pSelect, Id); }
	DLG_ITEMD *AddChoiceBox(int x, int y, int Width, int Height, char *pText, int Style, int *pSelect, COLOR Col[4], int Id)
		{ return GUI_DlgAddGChoiceBox(&m_Dialog, x, y, Width, Height, pText, Style, pSelect, Col, Id); }
	DLG_ITEMD *AddCheckIcon(int x, int y, int Width, int Height, const char *pLabel, CCImage *pIconList, int *pState, int Id);
	DLG_ITEMD *AddArea(int x, int y, int Width, int Height, int Id)
		{ return GUI_DlgAddArea(&m_Dialog, x, y, Width, Height, Id); }
	DLG_ITEMD *AddLogBox(int x, int y, int Width, int Height, char *pText, int Id)
		{ return GUI_DlgAddLogBox(&m_Dialog, x, y, Width, Height, pText, Id); }
	DLG_ITEMD *AddPageSelector(int x, int y, int Width, int Height, const char *pLabel, int Page, int Id)
		{ return GUI_DlgAddPageSelector(&m_Dialog, x, y, Width, Height, pLabel, Page, Id); }
	int AddAccel(char Accel, int Id)
		{ return GUI_DlgAddAccel(&m_Dialog, Accel, Id); }
	int RemoveItem(int Id)
		{ return GUI_DlgRemoveDItem(&m_Dialog, Id); }
	int RemoveItem(DLG_ITEMD *pItem)
		{ return GUI_DlgRemoveDItem2(&m_Dialog, pItem); }
	int RemoveItem(DLG_ITEMS *pItem)
		{ return GUI_DlgRemoveSItem(&m_Dialog, pItem); }
	//! \}

	//! \name Work
	//! \{
	int GetWidth() const
		{ return m_Dialog.rgbDlg.Width; }
	int GetHeight() const
		{ return m_Dialog.rgbDlg.Height; }
	void GetMousePos(int *pPosX, int *pPosY) const
		{ *pPosX = m_Dialog.PosX; *pPosY = m_Dialog.PosY; }
	void Refresh()
		{ GUI_DlgRefresh(&m_Dialog); }
	void RefreshItem(DLG_ITEMD *pDItem)
		{ GUI_DlgRefreshItem(&m_Dialog, pDItem); }
	void RefreshItem(DLG_ITEMS *pSItem)
		{ GUI_DlgRefreshSItem(&m_Dialog, pSItem); }
	void Paint(CCImage *pImage, int x, int y)
		{ GUI_DlgPaint(&m_Dialog, CCImage::CheckImgPtr(pImage), x, y); }
	void Paint(int x, int y)
		{ GUI_DlgPaint2(&m_Dialog, x, y); }
	void PaintS(CCImage *pImage, int x, int y)
		{ GUI_DlgPaintS(&m_Dialog, CCImage::CheckImgPtr(pImage), x, y); }
	void Update(CCImage *pImage, int x, int y)
		{ GUI_DlgUpdate(&m_Dialog, CCImage::CheckImgPtr(pImage), x, y); }
	void Update(int x, int y)
		{ GUI_DlgUpdate2(&m_Dialog, x, y); }
	void Update(DLG_ITEMD *pItem, int x, int y)
		{ GUI_DlgUpdate3(&m_Dialog, pItem, x, y); }
	void UpdateS(CCImage *pImage, int x, int y)
		{ GUI_DlgUpdateS(&m_Dialog, CCImage::CheckImgPtr(pImage), x, y); }
	void Draw(CCImage *pImage, int x, int y, int Refresh, int Shadow)
		{ GUI_DlgDraw(&m_Dialog, CCImage::CheckImgPtr(pImage), x, y, Refresh, Shadow); }
	void Show()
		{ GUI_DlgShow(&m_Dialog); }
	int Modal(CCImage *pImage, int x, int y, FILE *fKB)
		{ return GUI_DlgModal(&m_Dialog, CCImage::CheckImgPtr(pImage), x, y, fKB); }
	int Work(int nKey)
		{ return GUI_DlgWork(&m_Dialog, nKey); }
	int GetSelectedID()
		{ return GUI_DlgGetSelectedID(&m_Dialog); }
	int GetLastID()
		{ return GUI_DlgGetLastID(&m_Dialog); }
	int NextItem()
		{ return GUI_DlgNextItem(&m_Dialog); }
	int PrevItem()
		{ return GUI_DlgPrevItem(&m_Dialog); }
	int GotoItem(int ItemID)
		{ return GUI_DlgGotoItem(&m_Dialog, ItemID); }
	int GotoItem(DLG_ITEMD *pItem)
		{ return GUI_DlgGotoItem2(&m_Dialog, pItem); }
	int Resize(int Width, int Height)
		{ return GUI_DlgResize(&m_Dialog, Width, Height); }
	void Enable(int Enable)
		{ GUI_DlgEnable(&m_Dialog, Enable); }
	void SetTitle(const char *pTitle)
		{ GUI_DlgSetTitle(&m_Dialog, pTitle); }
	void SetFlags(int Flags)
		{ GUI_DlgSetFlags(&m_Dialog, Flags); }
	int GetFlags()
		{ return GUI_DlgGetFlags(&m_Dialog); }
	void SetPage(int Page)
		{ GUI_DlgSetPage(&m_Dialog, Page); }
	int GetPage()
		{ return GUI_DlgGetPage(&m_Dialog); }
	void SwitchPage(int Page)
		{ GUI_DlgSwitchPage(&m_Dialog, Page); }
	void SetBackCol(const COLOR *pBackCol)
		{ GUI_DlgSetBackCol(&m_Dialog, pBackCol); }
	void SetGradCol(COLOR GradCol[4])
		{ GUI_DlgSetGradCol(&m_Dialog, GradCol); }
	void SetBackImage(CCImage *pImage)
		{ GUI_DlgSetBackImage(&m_Dialog, CCImage::CheckImgPtr(pImage)); }
	void GetZeroZero(int *px, int *py)
		{ GUI_DlgGetZeroZero(&m_Dialog, px, py); }
	int GetItemType(int ItemID)
		{ return GUI_DlgGetItemType(&m_Dialog, ItemID); }
	void StoreValues()
		{ GUI_DlgStoreValues(&m_Dialog); }
	void RestoreValues()
		{ GUI_DlgRestoreValues(&m_Dialog); }
	//! \}

private:
	GUI_DLG m_Dialog; //!< Dialog structure
};

/******************************************************************************/
/*! @brief Dynamic Item class

	C++ interface for using dynamic dialog items.
*******************************************************************************/
class CDItem
{
public:
	//! \name Construction
	//! \{
	CDItem()
		{ m_pItem = NULL; }
	CDItem(DLG_ITEMD *pItem)
		{ m_pItem = pItem; }
	void Assign(DLG_ITEMD *pItem)
		{ m_pItem = pItem; }
	DLG_ITEMD *Get() const
		{ return m_pItem; }
	//! \}

	//! \name Modify item
	//! \{
	void ModifyButton(int x, int y, int Width, int Height, const char *pLabel)
		{ GUI_DlgModifyButton(m_pItem, x, y, Width, Height, pLabel); }
	void ModifyButton(int x, int y, int Width, int Height, const char *pLabel, COLOR Col[4])
		{ GUI_DlgModifyGButton(m_pItem, x, y, Width, Height, pLabel, Col); }
	void ModifyIconButton(int x, int y, int Width, int Height, const char *pLabel, CCImage *pIcon)
		{ GUI_DlgModifyIconButton(m_pItem, x, y, Width, Height, pLabel, &pIcon->m_Image); }
	void ModifyAnimButton(int x, int y, int Width, int Height, const char *pLabel, CCImage *pIconList, int NumIcons);
	void ModifyCheckBox(int x, int y, int Width, int Height, const char *pLabel)
		{ GUI_DlgModifyCheckBox(m_pItem, x, y, Width, Height, pLabel); }
	void ModifyCheckBox(int x, int y, int Width, int Height, const char *pLabel, COLOR Col[4])
		{ GUI_DlgModifyGCheckBox(m_pItem, x, y, Width, Height, pLabel, Col); }
	void ModifySEditBox(int x, int y, int Width)
		{ GUI_DlgModifySEditBox(m_pItem, x, y, Width); }
	void ModifyVEditBox(int x, int y, int Width, int Min, int Max)
		{ GUI_DlgModifyVEditBox(m_pItem, x, y, Width, Min, Max); }
	void ModifyVSpinBox(int x, int y, int Width, int Min, int Max)
		{ GUI_DlgModifyVSpinBox(m_pItem, x, y, Width, Min, Max); }
	void ModifySlider(int x, int y, int Width, int Height, int Min, int Max)
		{ GUI_DlgModifySlider(m_pItem, x, y, Width, Height, Min, Max); }
	void ModifyEditSlider(int x, int y, int Width, const char *pLabel, int Min, int Max)
		{ GUI_DlgModifyEditSlider(m_pItem, x, y, Width, pLabel, Min, Max); }
	void ModifySelectBox(int x, int y, int Width, int Height, char *pText)
		{ GUI_DlgModifySelectBox(m_pItem, x, y, Width, Height, pText); }
	void ModifyFileSelectBox(int x, int y, int Width, int Height, int Device, int Flags, const char *pFilter)
		{ GUI_DlgModifyFileSelectBox(m_pItem, x, y, Width, Height, Device, Flags, pFilter); }
	void ModifyListBox(int x, int y, int Width, int Height, char *pText[], int Elements)
		{ GUI_DlgModifyListBox(m_pItem, x, y, Width, Height, pText, Elements); }
	void ModifyChoiceBox(int x, int y, int Width, int Height, char *pText, int Style)
		{ GUI_DlgModifyChoiceBox(m_pItem, x, y, Width, Height, pText, Style); }
	void ModifyChoiceBox(int x, int y, int Width, int Height, char *pText, int Style, COLOR Col[4])
		{ GUI_DlgModifyGChoiceBox(m_pItem, x, y, Width, Height, pText, Style, Col); }
	void ModifyCheckIcon(int x, int y, int Width, int Height, const char *pLabel, CCImage *pIconList);
	void ModifyArea(int x, int y, int Width, int Height)
		{ GUI_DlgModifyArea(m_pItem, x, y, Width, Height); }
	void ModifyLogBox(int x, int y, int Width, int Height)
		{ GUI_DlgModifyLogBox(m_pItem, x, y, Width, Height); }
	void ModifyPageSelector(int x, int y, int Width, int Height, const char *pLabel, int Page)
		{ GUI_DlgModifyPageSelector(m_pItem, x, y, Width, Height, pLabel, Page); }
	//! \}

	//! \name Change item
	//! \{
	int IsSelected()
		{ return GUI_DlgIsDItemSelected(m_pItem); }
	void SetState(int State)
		{ GUI_DlgSetDItemState(m_pItem, State); }
	int GetState() const
		{ return GUI_DlgGetDItemState(m_pItem); }
	void SetPage(int Page)
		{ GUI_DlgSetDItemPage(m_pItem, Page); }
	int GetPage() const
		{ return GUI_DlgGetDItemPage(m_pItem); }
	int GetType() const
		{ return GUI_DlgGetItemType2(m_pItem); }
	void GetTxtParam(TEXTPARAMETER *pTP)
		{ GUI_DlgGetDItemTxtParam(m_pItem, pTP); }
	void SetTxtParam(const TEXTPARAMETER *pTP)
		{ GUI_DlgSetDItemTxtParam(m_pItem, pTP); }
	void SetAnimButton(int Icon)
		{ GUI_DlgSetAnimButton(m_pItem, Icon); }
	void SliderSetType(int Type)
		{ GUI_DlgSetSliderType(m_pItem, Type); }
	void EditSliderSetType(int Type)
		{ GUI_DlgSetEditSliderType(m_pItem, Type); }
	void LogBoxClear()
		{ GUI_DlgLogBoxClear(m_pItem); }
	void LogBoxPrint(const char *pText)
		{ GUI_DlgLogBoxPrint(m_pItem, pText); }
	void LogBoxPrintFormat(const char *pFormat, ...);
	const char *LogBoxGetText(int *pLength)
		{ return GUI_DlgLogBoxGetText(m_pItem, pLength); }
	void SelectBoxModifyText(char *pText)
		{ GUI_DlgModifySelectBoxText(m_pItem, pText); }
	void FileSelectBoxModifyLine(int Select)
		{ GUI_DlgModifyFileSelectBoxLine(m_pItem, Select); }
	void FileSelectBoxRefresh()
		{ GUI_DlgRefreshFileSelectBox(m_pItem); }
	int FileSelectBoxGetLine()
		{ return GUI_DlgGetFileSelectBoxLine(m_pItem); }
	int FileSelectBoxGetFSize()
		{ return GUI_DlgGetFileSelectBoxFSize(m_pItem); }
	void SetPageSelectorStyle(int Style)
		{ GUI_DlgSetPageSelectorStyle(m_pItem, Style); }
	//! \}

private:
	DLG_ITEMD *m_pItem; //!< Dynamic item structure
};

/******************************************************************************/
/*! @brief Static Item class

	C++ interface for using static dialog items.
*******************************************************************************/
class CSItem
{
public:
	//! \name Construction
	//! \{
	CSItem()
		{ m_pItem = NULL; }
	CSItem(DLG_ITEMS *pItem)
		{ m_pItem = pItem; }
	void Assign(DLG_ITEMS *pItem)
		{ m_pItem = pItem; }
	DLG_ITEMS *Get() const
		{ return m_pItem; }
	//! \}

	//! \name Modify item
	//! \{
	void ModifyText(int x, int y, const char *pLabel)
		{ GUI_DlgModifyText(m_pItem, x, y, pLabel); }
	void ModifyBorder(int x, int y, int Width, int Height, int Style)
		{ GUI_DlgModifyBorder(m_pItem, x, y, Width, Height, Style); }
	void ModifyIcon(int x, int y, CCImage *pIcon)
		{ GUI_DlgModifyIcon(m_pItem, x, y, CCImage::CheckImgPtr(pIcon)); }
	void ModifyAnimIcon(int x, int y, CCImage *pIconList, int NumIcons);
	void ModifyTextBox(int x, int y, int Width, int Height, const char *pString, int Style)
		{ GUI_DlgModifyTextBox(m_pItem, x, y, Width, Height, pString, Style); }
	//! \}

	//! \name Change item
	//! \{
	void SetState(int State)
		{ GUI_DlgSetSItemState(m_pItem, State); }
	int GetState() const
		{ return GUI_DlgGetSItemState(m_pItem); }
	void SetPage(int Page)
		{ GUI_DlgSetSItemPage(m_pItem, Page); }
	int GetPage() const
		{ return GUI_DlgGetSItemPage(m_pItem); }
	void SetAnimIcon(int Icon)
		{ GUI_DlgSetAnimIcon(m_pItem, Icon); }
	void ChangeText(const char *pLabel)
		{ GUI_DlgChangeText(m_pItem, pLabel); }
	//! \}

private:
	DLG_ITEMS *m_pItem; //!< Static item structure
};

/******************************************************************************/
/*! @brief TextParameter class

	C++ interface for using Text parameter.
*******************************************************************************/
class CTextParameter
{
public:
	CTextParameter(int Init = 0)
		{ if (Init) GUI_InitTxtParam(&m_TP); }
	CTextParameter(TEXTPARAMETER *pTP)
		{ m_TP = *pTP; }

	TEXTPARAMETER *GetTP()
		{ return &m_TP; }

	void Init()
		{ GUI_InitTxtParam(&m_TP); }
	void Get()
		{ GUI_GetTxtParam(&m_TP); }
	void Get(TEXTPARAMETER *pTP)
		{ m_TP = *pTP; }
	void Set()
		{ GUI_SetTxtParam(&m_TP); }
	void Set(TEXTPARAMETER *pTP)
		{ *pTP = m_TP; }

	TEXTPARAMETER m_TP;	//!< Text parameter structure
};

/******************************************************************************/

#endif
