⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 api_core.h

📁 这是一个GPS相关的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
	SG_FILE_R,
	SG_FILE_W,
	SG_FILE_RW,
	SG_FILE_WA,
	SG_FILE_RWA
};

//---------------------------------------------------------
enum
{
	SG_FILE_START,
	SG_FILE_CURRENT,
	SG_FILE_END
};

//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_File
{
public:

	CSG_File(void);
	CSG_File(const CSG_String &File_Name, int Mode = SG_FILE_R, bool bBinary = true);

	virtual ~CSG_File(void);

	bool							Attach				(FILE *Stream);
	bool							Detach				(void);
	FILE *							Get_Stream			(void)	const	{	return( m_pStream );	}

	bool							Open				(const CSG_String &FileName, int Mode = SG_FILE_R, bool bBinary = true);
	bool							Close				(void);

	bool							is_Open				(void)	const	{	return( m_pStream != NULL );	}
	bool							is_EOF				(void)	const;

	int								Length				(void)	const;

	bool							Seek				(int Offset, int Origin = SG_FILE_START)	const;
	bool							Seek_Start			(void)	const;
	bool							Seek_End			(void)	const;

	int								Tell				(void)	const;

	bool							Flush				(void)	const;

	int								Printf				(const SG_Char *Format, ...);
	int								Scanf				(const SG_Char *Format, ...)	const;

	size_t							Read				(void       *Buffer, size_t Size, size_t Count = 1)	const;
	size_t							Write				(void       *Buffer, size_t Size, size_t Count = 1)	const;
	size_t							Read				(CSG_String &Buffer, size_t Size)	const;
	size_t							Write				(CSG_String &Buffer)				const;

	bool							Read_Line			(CSG_String &sLine);

	int								Read_Int			(				bool bByteOrderBig);
	bool							Write_Int			(int    Value,	bool bByteOrderBig);
	double							Read_Double			(				bool bByteOrderBig);
	bool							Write_Double		(double Value,	bool bByteOrderBig);


protected:

	FILE							*m_pStream;

};

//---------------------------------------------------------
SAGA_API_DLL_EXPORT bool			SG_Dir_Exists			(const SG_Char *Directory);
SAGA_API_DLL_EXPORT bool			SG_Dir_Create			(const SG_Char *Directory);
SAGA_API_DLL_EXPORT CSG_String		SG_Dir_Get_Current		(void);

SAGA_API_DLL_EXPORT bool			SG_File_Exists			(const SG_Char *FileName);
SAGA_API_DLL_EXPORT bool			SG_File_Delete			(const SG_Char *FileName);
SAGA_API_DLL_EXPORT CSG_String		SG_File_Get_TmpName		(const SG_Char *Prefix, const SG_Char *Directory);
SAGA_API_DLL_EXPORT CSG_String		SG_File_Get_Name		(const SG_Char *full_Path, bool bExtension);
SAGA_API_DLL_EXPORT CSG_String		SG_File_Get_Path		(const SG_Char *full_Path);
SAGA_API_DLL_EXPORT CSG_String		SG_File_Make_Path		(const SG_Char *Directory, const SG_Char *Name, const SG_Char *Extension = NULL);
SAGA_API_DLL_EXPORT bool			SG_File_Cmp_Extension	(const SG_Char *File_Name, const SG_Char *Extension);

SAGA_API_DLL_EXPORT bool			SG_Read_Line			(FILE *Stream, CSG_String &Line);


///////////////////////////////////////////////////////////
//														 //
//						Colors							 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
#define SG_GET_RGB(r, g, b)			((DWORD) (((BYTE)(r) | ((WORD)(g) << 8)) | (((DWORD)(BYTE)(b)) << 16)))
#define SG_GET_RGBA(r, g, b, a)		((DWORD) (((BYTE)(r) | ((WORD)(g) << 8)) | (((DWORD)(BYTE)(b)) << 16) | (((DWORD)(BYTE)(a)) << 24)))

#define SG_GET_R(rgb)				((BYTE) ((rgb)      ))
#define SG_GET_G(rgb)				((BYTE) ((rgb) >>  8))
#define SG_GET_B(rgb)				((BYTE) ((rgb) >> 16))
#define SG_GET_A(rgb)				((BYTE) ((rgb) >> 24))

//---------------------------------------------------------
#define SG_COLOR_BLACK				SG_GET_RGB(  0,   0,   0)
#define SG_COLOR_GREY				SG_GET_RGB(128, 128, 128)
#define SG_COLOR_GREY_LIGHT			SG_GET_RGB(192, 192, 192)
#define SG_COLOR_WHITE				SG_GET_RGB(255, 255, 255)
#define SG_COLOR_RED				SG_GET_RGB(255,   0,   0)
#define SG_COLOR_RED_DARK			SG_GET_RGB(128,   0,   0)
#define SG_COLOR_YELLOW				SG_GET_RGB(255, 255,   0)
#define SG_COLOR_YELLOW_DARK		SG_GET_RGB(128, 128,   0)
#define SG_COLOR_GREEN				SG_GET_RGB(  0, 255,   0)
#define SG_COLOR_GREEN_DARK			SG_GET_RGB(  0, 128,   0)
#define SG_COLOR_GREEN_LIGHT		SG_GET_RGB(  0, 255,   0)
#define SG_COLOR_BLUE				SG_GET_RGB(  0,   0, 255)
#define SG_COLOR_BLUE_DARK			SG_GET_RGB(  0,   0, 128)
#define SG_COLOR_BLUE_LIGHT			SG_GET_RGB(  0, 255, 255)
#define SG_COLOR_BLUE_GREEN			SG_GET_RGB(  0, 128, 128)
#define SG_COLOR_PURPLE				SG_GET_RGB(128,   0, 128)
#define SG_COLOR_PINK				SG_GET_RGB(255,   0, 255)
#define SG_COLOR_NONE				-1
#define SG_COLOR_RANDOM				-2

//---------------------------------------------------------
enum ESG_Colors
{
	SG_COLORS_DEFAULT			= 0,
	SG_COLORS_DEFAULT_BRIGHT,
	SG_COLORS_BLACK_WHITE,
	SG_COLORS_BLACK_RED,
	SG_COLORS_BLACK_GREEN,
	SG_COLORS_BLACK_BLUE,
	SG_COLORS_WHITE_RED,
	SG_COLORS_WHITE_GREEN,
	SG_COLORS_WHITE_BLUE,
	SG_COLORS_YELLOW_RED,
	SG_COLORS_YELLOW_GREEN,
	SG_COLORS_YELLOW_BLUE,
	SG_COLORS_RED_GREEN,
	SG_COLORS_RED_BLUE,
	SG_COLORS_GREEN_BLUE,
	SG_COLORS_RED_GREY_BLUE,
	SG_COLORS_RED_GREY_GREEN,
	SG_COLORS_GREEN_GREY_BLUE,
	SG_COLORS_RED_GREEN_BLUE,
	SG_COLORS_RED_BLUE_GREEN,
	SG_COLORS_GREEN_RED_BLUE,
	SG_COLORS_RAINBOW,
	SG_COLORS_NEON,
	SG_COLORS_COUNT
};

//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Colors
{
public:
	CSG_Colors(void);
	CSG_Colors(const CSG_Colors &Colors);
	CSG_Colors(int nColors, int Palette = SG_COLORS_DEFAULT, bool bRevert = false);
	virtual ~CSG_Colors(void);

	void							Destroy				(void);

	bool							Set_Count			(int nColors);
	int								Get_Count			(void) const		{	return( m_nColors );	}

	CSG_Colors &					operator  =			(const CSG_Colors &Colors);
	long &							operator []			(int Index)			{	return( m_Colors[Index] );	}

	bool							Set_Color			(int Index, long Color);
	bool							Set_Color			(int Index, int Red, int Green, int Blue);
	bool							Set_Red				(int Index, int Value);
	bool							Set_Green			(int Index, int Value);
	bool							Set_Blue			(int Index, int Value);
	bool							Set_Brightness		(int Index, int Value);

	long							Get_Color			(int Index) const	{	return( Index >= 0 && Index < m_nColors ? m_Colors[Index] : 0 );	}
	long							Get_Red				(int Index) const	{	return( SG_GET_R(Get_Color(Index)) );	}
	long							Get_Green			(int Index) const	{	return( SG_GET_G(Get_Color(Index)) );	}
	long							Get_Blue			(int Index) const	{	return( SG_GET_B(Get_Color(Index)) );	}
	long							Get_Brightness		(int Index) const	{	return( (Get_Red(Index) + Get_Green(Index) + Get_Blue(Index)) / 3 );	}

	bool							Set_Default			(int nColors = 100);
	bool							Set_Palette			(int Index, bool bRevert = false, int nColors = 100);
	bool							Set_Ramp			(long Color_A, long Color_B);
	bool							Set_Ramp			(long Color_A, long Color_B, int iColor_A, int iColor_B);
	bool							Set_Ramp_Brighness	(int Brightness_A, int Brightness_B);
	bool							Set_Ramp_Brighness	(int Brightness_A, int Brightness_B, int iColor_A, int iColor_B);

	bool							Random				(void);
	bool							Invert				(void);
	bool							Revert				(void);

	bool							Assign				(const CSG_Colors &Colors);
	bool							Assign				(CSG_Colors *pSource);

	bool							Load				(const SG_Char *File_Name);
	bool							Save				(const SG_Char *File_Name, bool bBinary);

	bool							Serialize			(CSG_File &Stream, bool bSave, bool bBinary);


private:

	int								m_nColors;

	long							*m_Colors;


	void							_Set_Brightness		(double &a, double &b, double &c, int Pass = 0);

};


///////////////////////////////////////////////////////////
//														 //
//						Translator						 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Translator
{
private:

	class CTranslation
	{
	public:
		CTranslation(const SG_Char *Text, const SG_Char *Translation)
		{
			m_Text					= Text;
			m_Translation			= Translation;
		}

		~CTranslation(void)	{}

		CSG_String					m_Text, m_Translation;
	};


public:
	CSG_Translator(void);
	CSG_Translator(const SG_Char *File_Name, bool bSetExtension = true);

	virtual ~CSG_Translator(void);

	bool							Create				(const SG_Char *File_Name, bool bSetExtension = true);
	void							Destroy				(void);

	int								Get_Count			(void)	{	return( m_nTranslations );	}

	const SG_Char *					Get_Text			(int Index);
	const SG_Char *					Get_Translation		(int Index);

	const SG_Char *					Get_Translation		(const SG_Char *Text);


private:

	int								m_nTranslations;

	CTranslation					**m_Translations;


	void							_Add_Translation	(const SG_Char *Text, const SG_Char *Translation);
	int								_Get_Index			(const SG_Char *Text);

};

//---------------------------------------------------------
SAGA_API_DLL_EXPORT CSG_Translator *	SG_Get_Translator	(void);

SAGA_API_DLL_EXPORT const SG_Char *		SG_Translate		(const SG_Char *Text);

#ifndef _SAGA_UNICODE
	#define LNG(s)	SG_Translate(s)
#else
	#define LNG(s)	SG_Translate(SG_T(s))
#endif


///////////////////////////////////////////////////////////
//														 //
//						UI Callback						 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
typedef enum ESG_UI_Callback_ID
{
	CALLBACK_PROCESS_GET_OKAY,
	CALLBACK_PROCESS_SET_OKAY,
	CALLBACK_PROCESS_SET_PROGRESS,
	CALLBACK_PROCESS_SET_READY,
	CALLBACK_PROCESS_SET_TEXT,

	CALLBACK_DLG_MESSAGE,
	CALLBACK_DLG_CONTINUE,
	CALLBACK_DLG_ERROR,

	CALLBACK_DLG_PARAMETERS,

	CALLBACK_MESSAGE_ADD,
	CALLBACK_MESSAGE_ADD_ERROR,
	CALLBACK_MESSAGE_ADD_EXECUTION,

	CALLBACK_DATAOBJECT_FIND_BY_FILE,
	CALLBACK_DATAOBJECT_CHECK,
	CALLBACK_DATAOBJECT_ADD,
	CALLBACK_DATAOBJECT_UPDATE,
	CALLBACK_DATAOBJECT_SHOW,
	CALLBACK_DATAOBJECT_ASIMAGE,

	CALLBACK_DATAOBJECT_COLORS_GET,
	CALLBACK_DATAOBJECT_COLORS_SET,
	CALLBACK_DATAOBJECT_PARAMS_GET,
	CALLBACK_DATAOBJECT_PARAMS_SET,

	CALLBACK_DATAOBJECT_GET_ALL,

	CALLBACK_GUI_GET_WINDOW
}
TSG_UI_Callback_ID;

//---------------------------------------------------------
typedef int (* TSG_PFNC_UI_Callback) (TSG_UI_Callback_ID ID, long pParam_1, long pParam_2);

//---------------------------------------------------------
SAGA_API_DLL_EXPORT bool					SG_Set_UI_Callback			(TSG_PFNC_UI_Callback Function);
SAGA_API_DLL_EXPORT TSG_PFNC_UI_Callback	SG_Get_UI_Callback			(void);

//---------------------------------------------------------
SAGA_API_DLL_EXPORT bool					SG_UI_Process_Get_Okay		(bool bBlink);
SAGA_API_DLL_EXPORT bool					SG_UI_Process_Set_Okay		(bool bOkay = true);
SAGA_API_DLL_EXPORT bool					SG_UI_Process_Set_Progress	(double Position, double Range);
SAGA_API_DLL_EXPORT bool					SG_UI_Process_Set_Ready		(void);
SAGA_API_DLL_EXPORT void					SG_UI_Process_Set_Text		(const SG_Char *Text);

SAGA_API_DLL_EXPORT void					SG_UI_Dlg_Message			(const SG_Char *Message, const SG_Char *Caption);
SAGA_API_DLL_EXPORT bool					SG_UI_Dlg_Continue			(const SG_Char *Message, const SG_Char *Caption);
SAGA_API_DLL_EXPORT int						SG_UI_Dlg_Error				(const SG_Char *Message, const SG_Char *Caption);
SAGA_API_DLL_EXPORT bool					SG_UI_Dlg_Parameters		(class CSG_Parameters *pParameters, const SG_Char *Caption);

SAGA_API_DLL_EXPORT void					SG_UI_Msg_Add				(const SG_Char *Message, bool bNewLine);
SAGA_API_DLL_EXPORT void					SG_UI_Msg_Add_Error			(const SG_Char *Message);
SAGA_API_DLL_EXPORT void					SG_UI_Msg_Add_Execution		(const SG_Char *Message, bool bNewLine);

SAGA_API_DLL_EXPORT class CSG_Data_Object *	SG_UI_DataObject_Find		(const SG_Char *File_Name             , int Object_Type);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Check		(class CSG_Data_Object *pDataObject, int Object_Type);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Add		(class CSG_Data_Object *pDataObject, bool bShow);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Update		(class CSG_Data_Object *pDataObject, bool bShow, class CSG_Parameters *pParameters);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Show		(class CSG_Data_Object *pDataObject);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_asImage	(class CSG_Data_Object *pDataObject, class CSG_Grid *pGrid);

SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Colors_Get	(class CSG_Data_Object *pDataObject, class CSG_Colors *pColors);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Colors_Set	(class CSG_Data_Object *pDataObject, class CSG_Colors *pColors);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Params_Get	(class CSG_Data_Object *pDataObject, class CSG_Parameters *pParameters);
SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Params_Set	(class CSG_Data_Object *pDataObject, class CSG_Parameters *pParameters);

SAGA_API_DLL_EXPORT bool					SG_UI_DataObject_Get_All	(class CSG_Parameters *pParameters);

SAGA_API_DLL_EXPORT void *					SG_UI_Get_Window_Main		(void);


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
#endif // #ifndef HEADER_INCLUDED__SAGA_API__api_core_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -