//
//	ToolLib_DxLib.cpp
//
//	エディター共通処理 - DxLib用のバックエンド
//
//	* Wed Apr 19 22:11:14 JST 2017 Naoyuki Sawa
//	- 1st リリース。
//
#include "clip.h"
//*****************************************************************************
//	
//*****************************************************************************
static int fnDrawBox(int x1, int y1, int x2, int y2, unsigned Color, int FillFlag) { return DrawBox(x1, y1, x2, y2, Color, FillFlag); }
static int fnDrawStringToHandle(int x, int y, const char* String, unsigned Color, int FontHandle/*, unsigned EdgeColor = 0, int VerticalFlag = 0*/) { return DrawStringToHandle(x, y, String, Color, FontHandle); }
static int fnDrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, unsigned Color, int FillFlag) { return DrawTriangle(x1, y1, x2, y2, x3, y3, Color, FillFlag); }
static unsigned fnGetColor(int Red, int Green, int Blue) { return GetColor(Red, Green, Blue); }
static int fnGetDrawScreenSize(int* XBuf, int* YBuf) { return GetDrawScreenSize(XBuf, YBuf); }
static int fnGetDrawStringWidthToHandle(const char* String, int StrLen, int FontHandle/*, int VerticalFlag = 0*/) { return GetDrawStringWidthToHandle(String, StrLen, FontHandle); }
static int fnGetMouseInput() { return GetMouseInput(); }
static int fnGetMousePoint(int* XBuf, int* YBuf) { return GetMousePoint(XBuf, YBuf); }
static int fnSetDrawArea(int x1, int y1, int x2, int y2) { return SetDrawArea(x1, y1, x2, y2); }
static int fnSetDrawAreaFull() { return SetDrawAreaFull(); }
static int fnSetDrawBlendMode(int BlendMode, int BlendParam) { return SetDrawBlendMode(BlendMode, BlendParam); }
#ifdef  TOOLLIB_USE_STRINGINPUT
static int fnCheckKeyInput(int InputHandle) { return CheckKeyInput(InputHandle); }
static int fnDeleteKeyInput(int InputHandle) { return DeleteKeyInput(InputHandle); }
static int fnDrawKeyInputString(int x, int y, int InputHandle) { return DrawKeyInputString(x, y, InputHandle); }
static int fnGetActiveKeyInput() { return GetActiveKeyInput(); }
static int fnGetClipboardText(char* DestBuffer) { return GetClipboardText(DestBuffer); }
static int fnGetKeyInputDrawStartPos(int InputHandle) { return GetKeyInputDrawStartPos(InputHandle); }
static int fnGetKeyInputNumber(int InputHandle) { return GetKeyInputNumber(InputHandle); }
static float fnGetKeyInputNumberToFloat(int InputHandle) { return GetKeyInputNumberToFloat(InputHandle); }
static int fnGetKeyInputSelectArea(int* SelectStart, int* SelectEnd, int InputHandle) { return GetKeyInputSelectArea(SelectStart, SelectEnd, InputHandle); }
static int fnGetKeyInputString(char* StrBuffer, int InputHandle) { return GetKeyInputString(StrBuffer, InputHandle); }
static HWND fnGetMainWindowHandle() { return GetMainWindowHandle(); }
static int fnMakeKeyInput(size_t MaxStrLength, int CancelValidFlag, int SingleCharOnlyFlag, int NumCharOnlyFlag/*, int DoubleCharOnlyFlag = 0, int EnableNewLineFlag = 0*/) { return MakeKeyInput(MaxStrLength, CancelValidFlag, SingleCharOnlyFlag, NumCharOnlyFlag); }
static int fnMultiByteCharCheck(const char* Buf, int CharSet) { return MultiByteCharCheck(Buf, CharSet); }
static int fnRectClipping(RECT* Rect, const RECT* ClippuRect) { return RectClipping(Rect, ClippuRect); }
static int fnReStartKeyInput(int InputHandle) { return ReStartKeyInput(InputHandle); }
static int fnSetActiveKeyInput(int InputHandle) { return SetActiveKeyInput(InputHandle); }
static int fnSetClipboardText(const char* Text) { return SetClipboardText(Text); }
static int fnSetKeyInputCursorPosition(int Position, int InputHandle) { return SetKeyInputCursorPosition(Position, InputHandle); }
static int fnSetKeyInputNumber(int Number, int InputHandle) { return SetKeyInputNumber(Number, InputHandle); }
static int fnSetKeyInputNumberToFloat(float Number, int InputHandle) { return SetKeyInputNumberToFloat(Number, InputHandle); }
static int fnSetKeyInputSelectArea(int SelectStart, int SelectEnd, int InputHandle) { return SetKeyInputSelectArea(SelectStart, SelectEnd, InputHandle); }
static int fnSetKeyInputString(const char* String, int InputHandle) { return SetKeyInputString(String, InputHandle); }
static int fnSetKeyInputStringColor(uint64_t NmlStr, uint64_t NmlCur, uint64_t IMEStrBack, uint64_t IMECur, uint64_t IMELine, uint64_t IMESelectStr, uint64_t IMEModeStr/*, uint64_t NmlStrE = 0, uint64_t IMESelectStrE = 0, uint64_t IMEModeStrE = 0, uint64_t IMESelectWinE = -1, uint64_t IMESelectWinF = -1, uint64_t SelectStrBackColor = -1, uint64_t SelectStrColor = -1, uint64_t SelectStrEdgeColor = -1, uint64_t IMEStr = -1, uint64_t IMEStrE = -1*/) { return SetKeyInputStringColor(NmlStr, NmlCur, IMEStrBack, IMECur, IMELine, IMESelectStr, IMEModeStr); }
static int fnSetKeyInputStringFont(int FontHandle) { return SetKeyInputStringFont(FontHandle); }
static int fnStockInputChar(char CharCode) { return StockInputChar(CharCode); }
#endif//TOOLLIB_USE_STRINGINPUT
//*****************************************************************************
//	アプリケーション用関数
//*****************************************************************************
//□使用例
//│int cpp_main(int argc, char* argv[]) {
//│  SToolInfo ToolInfo;
//│  ToolDxLib_GetDefault(&ToolInfo);
//│  //必要に応じてここでToolInfoの一部のフィールドをアプリケーション定義の関数等に置き換える事も出来ます。
//│  Tool_Initialize(&ToolInfo);
//│  for(;;) {
//│    〜
//│  }
//│  Tool_Terminate();
//│}
void ToolDxLib_GetDefault(SToolInfo* pToolInfo) {
	static SToolInfo g_ToolInfo={
		fnDrawBox,
		fnDrawStringToHandle,
		fnDrawTriangle,
		fnGetColor,
		fnGetDrawScreenSize,
		fnGetDrawStringWidthToHandle,
		fnGetMouseInput,
		fnGetMousePoint,
		fnSetDrawArea,
		fnSetDrawAreaFull,
		fnSetDrawBlendMode,
	#ifdef  TOOLLIB_USE_STRINGINPUT
		fnCheckKeyInput,
		fnDeleteKeyInput,
		fnDrawKeyInputString,
		fnGetActiveKeyInput,
		fnGetClipboardText,
		fnGetKeyInputDrawStartPos,
		fnGetKeyInputNumber,
		fnGetKeyInputNumberToFloat,
		fnGetKeyInputSelectArea,
		fnGetKeyInputString,
		fnGetMainWindowHandle,
		fnMakeKeyInput,
		fnMultiByteCharCheck,
		fnRectClipping,
		fnReStartKeyInput,
		fnSetActiveKeyInput,
		fnSetClipboardText,
		fnSetKeyInputCursorPosition,
		fnSetKeyInputNumber,
		fnSetKeyInputNumberToFloat,
		fnSetKeyInputSelectArea,
		fnSetKeyInputString,
		fnSetKeyInputStringColor,
		fnSetKeyInputStringFont,
		fnStockInputChar,
	#endif//TOOLLIB_USE_STRINGINPUT
		-1,	//NormalFontHandle
		-1,	//ButtonFontHandle
	};
	//初回ならば、フォントを作成する。
	if(g_ToolInfo.NormalFontHandle == -1) {
		g_ToolInfo.NormalFontHandle = CreateFontToHandle(NULL,TOOL_BUTTON_FONT_HEIGHT,0,DX_FONTTYPE_EDGE  );
		if(g_ToolInfo.NormalFontHandle == -1) { DIE(); }
	}
	if(g_ToolInfo.ButtonFontHandle == -1) {
		g_ToolInfo.ButtonFontHandle = CreateFontToHandle(NULL,TOOL_BUTTON_FONT_HEIGHT,0,DX_FONTTYPE_NORMAL);
		if(g_ToolInfo.ButtonFontHandle == -1) { DIE(); }
	}
	*pToolInfo = g_ToolInfo;
}
