?? tft_api.c
字號:
short W, H;
if(((Handle < 0) && (Handle >= MAX_WINDOW)) || (Window->Flag == 0))
return 0;
TFT_GetWorkBufSize(&W, &H);
if((TLx >= W) || (TLy >= H))
return 0;
if((TLx == Window->TLx) && (TLy == Window->TLy))
return 0;
if(TLx >= 0)
{
x1 = Window->TLx >= 0 ? Window->TLx : 0;
}
else
{
x1 = Window->TLx - TLx >= 0 ? Window->TLx - TLx : 0;
}
if(TLy >= 0)
{
y1 = Window->TLy >= 0 ? Window->TLy : 0;
}
else
{
y1 = Window->TLy - TLy >= 0 ? Window->TLy - TLy : 0;
}
x2 = (TLx + Window->Width) < W ? Window->BRx : Window->TLx - TLx + W;
y2 = (TLy + Window->Height) < H ? Window->BRy : Window->TLy - TLy + H;
Dx1 = x1 - Window->TLx + TLx;
Dy1 = y1 - Window->TLy + TLy;
Dx2 = x2 + TLx - Window->TLx;
Dy2 = y2 + TLy - Window->TLy;
TFT_CopyRectToBuffer(TempBuf, x1, y1, x2, y2);
if(Cut)
{
COLOR BGBack = TFT_GetBGColor(Handle);
TFT_SetBGColor(Handle, COLOR_BLACK);
TFT_ClearWindow(Handle);
TFT_SetBGColor(Handle, BGBack);
}
TFT_CopyBufferToRect(TempBuf, Dx1, Dy1, Dx2, Dy2);
Window->TLx = TLx;
Window->TLy = TLy;
Window->BRx = TLx + Window->Width - 1;
Window->BRy = TLy + Window->Height - 1;
return 1;
}
#if 0
//=============================================================
//語法格式: int TFT_CopyWindow(WIN_HANDLE Handle, short TLx, short TLy)
//實現功能: 移動并復制窗口
//參數: Handle - 窗口句柄
// TLx,TLy - 新位置左上角坐標
//返回值: 1: 成功; 0:失敗
//=============================================================
int TFT_CopyWindow(WIN_HANDLE Handle, short TLx, short TLy)
{
return TFT_MoveWindowEx(Handle, TLx, TLy, 0);
}
//=============================================================
//語法格式: int TFT_MoveWindow(WIN_HANDLE Handle, short TLx, short TLy)
//實現功能: 移動窗口
//參數: Handle - 窗口句柄
// TLx,TLy - 新位置左上角坐標
//返回值: 1: 成功; 0:失敗
//=============================================================
int TFT_MoveWindow(WIN_HANDLE Handle, short TLx,short TLy)
{
return TFT_MoveWindowEx(Handle, TLx, TLy, 1);
}
#endif
//=============================================================
//語法格式: int TFT_ResetWindow(WIN_HANDLE Handle, short TLx, short TLy, short BRx, short BRy)
//實現功能: 重設窗口
//參數: Handle - 窗口句柄
// TLx,TLy - 新位置左上角坐標
// BRx,BRy - 新位置右下角坐標
//返回值: 1: 成功; 0:失敗
//=============================================================
int TFT_ResetWindow(WIN_HANDLE Handle, short TLx, short TLy, short BRx, short BRy)
{
STR_WINDOW *Window = g_WinList + Handle;
short W, H;
short TLxSet, TLySet, BRxSet, BRySet;
if((Handle < 0) && (Handle >= MAX_WINDOW))
return 0;
TFT_GetWorkBufSize(&W, &H);
TLxSet = TLx < BRx ? TLx : BRx;
if(TLxSet > W)
return 0;
TLySet = TLy < BRy ? TLy : BRy;
if(TLySet > H)
return 0;
BRxSet = TLx > BRx ? TLx : BRx;
if(BRxSet >= W)
BRxSet = W - 1;
BRySet = TLy >= BRy ? TLy : BRy;
if(BRySet > H)
BRySet = H - 1;
if(((TLxSet < 0) && (BRxSet < 0))
|| ((TLySet < 0) && (BRySet < 0)))
return 0;
Window->TLx = TLxSet;
Window->TLy = TLySet;
Window->BRx = BRxSet;
Window->BRy = BRySet;
Window->Width = BRxSet - TLxSet + 1;
Window->Height = BRySet - TLySet + 1;
return 1;
}
//=============================================================
//語法格式: int TFT_MoveWindowBorder(WIN_HANDLE Handle, short TLx, short TLy)
//實現功能: 移動窗口邊框
//參數: Handle - 窗口句柄
// TLx,TLy - 新位置左上角坐標
//返回值: 1: 成功; 0:失敗
//=============================================================
int TFT_MoveWindowBorder(WIN_HANDLE Handle, short TLx, short TLy)
{
STR_WINDOW *Window = g_WinList + Handle;
return TFT_ResetWindow(Handle, TLx, TLy, TLx + Window->Width - 1, TLy + Window->Height - 1);
}
//=============================================================
//語法格式: void TFT_ClearWindow(STR_WINDOW *Window)
//實現功能: 工作窗口清屏
//參數: Window - 工作窗口指針
//返回值: 無
//=============================================================
void TFT_ClearWindow(WIN_HANDLE Handle)
{
STR_WINDOW *Window = g_WinList + Handle;
short W, H;
short i, j;
unsigned short *p_Buf;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return;
TFT_GetWorkBufSize(&W, &H);
for(i = (Window->TLy >= 0 ? Window->TLy : 0); i <= Window->BRy; i++)
{
p_Buf = TFT_SelWorkBuf(-1) + i * W;
for(j=(Window->TLx >= 0 ? Window->TLx : 0); j <= Window->BRx; j++)
{
*(p_Buf+j) = Window->BGColor;
}
}
Window->CurTextX = Window->CurTextY = 0; // 窗口初始文本繪制坐標
}
//=============================================================
//語法格式: void TFT_SetTransparency(STR_WINDOW *Window, unsigned short TransparencySet);
//實現功能: 設置新顯示內容的透明度
//參數: Window - 工作窗口指針
// TransparencySet - 透明度參數,范圍0~100(0為不透明,100為全透明)
//返回值: 無
//=============================================================
void TFT_SetTransparency(WIN_HANDLE Handle, unsigned short TransparencySet)
{
STR_WINDOW *Window = g_WinList + Handle;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return;
Window ->Transparency = TransparencySet * 128 / 100; // 內部采用128級,以減少計算量
if(Window ->Transparency > 128)
Window ->Transparency = 128;
}
//=============================================================
//語法格式: unsigned short TFT_GetTransparency(STR_WINDOW *Window);
//實現功能: 獲取當前設定的透明度
//參數: Window - 工作窗口指針
//返回值: 透明度參數,范圍0~100(0為不透明,100為全透明)
//=============================================================
unsigned short TFT_GetTransparency(WIN_HANDLE Handle)
{
STR_WINDOW *Window = g_WinList + Handle;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return 0;
return (Window ->Transparency * 100)>>7;
}
//=============================================================
//語法格式: void TFT_SetColor(STR_WINDOW *Window, unsigned short ColorSet);
//實現功能: 設置顯示內容的前景色
//參數: Window - 工作窗口指針
// ColorSet - 顏色代碼,以16位存儲,格式為RRRRR-GGGGGG-BBBBB
//返回值: 無
//=============================================================
void TFT_SetColor(WIN_HANDLE Handle, unsigned short ColorSet)
{
STR_WINDOW *Window = g_WinList + Handle;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return;
Window->FGColor = ColorSet;
}
//=============================================================
//語法格式: unsigned short TFT_GetColor(STR_WINDOW *Window);
//實現功能: 獲取當前設定的前景色
//參數: Window - 工作窗口指針
//返回值: 顏色代碼,以16位存儲,格式為RRRRR-GGGGGG-BBBBB
//=============================================================
unsigned short TFT_GetColor(WIN_HANDLE Handle)
{
STR_WINDOW *Window = g_WinList + Handle;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return 0;
return Window->FGColor;
}
//=============================================================
//語法格式: unsigned short TFT_PickColor(STR_WINDOW *Window, short x, short y);
//實現功能: 獲取工作區內指定坐標像素的顏色
//參數: Window - 工作窗口指針
// x - 相對于工作區的x坐標
// y - 相對于工作區的y坐標
//返回值: 顏色代碼,以16位存儲,格式為RRRRR-GGGGGG-BBBBB
//=============================================================
unsigned short TFT_PickColor(WIN_HANDLE Handle, short x, short y)
{
STR_WINDOW *Window = g_WinList + Handle;
short AbsX, AbsY;
short W, H;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return 0;
TFT_GetWorkBufSize(&W, &H);
AbsX = Window->TLx + x;
AbsY = Window->TLy + y;
if((AbsX<0)||(AbsY<0)||(AbsX>=W)||(AbsY>=H))
return 0x0000;
return *(TFT_SelWorkBuf(-1) + AbsY * W + AbsX);
}
//=============================================================
//語法格式: unsigned short TFT_PickColorAbsolute(STR_WINDOW *Window, short AbsX, short AbsY);
//實現功能: 獲取顯示緩沖區中指定坐標像素的顏色
//參數: Window - 工作窗口指針
// AbsX - 相對于屏幕的x坐標
// AbsY - 相對于屏幕的y坐標
//返回值: 顏色代碼,以16位存儲,格式為RRRRR-GGGGGG-BBBBB
//=============================================================
unsigned short TFT_PickColorAbsolute(WIN_HANDLE Handle, short AbsX, short AbsY)
{
STR_WINDOW *Window = g_WinList + Handle;
short W, H;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return 0;
TFT_GetWorkBufSize(&W, &H);
if((AbsX<0)||(AbsY<0)||(AbsX>=W)||(AbsY>=H))
return 0x0000;
return *(TFT_SelWorkBuf(-1) + AbsY * W + AbsX);
}
//=============================================================
//語法格式: void TFT_SetBGColor(STR_WINDOW *Window, unsigned short ColorSet);
//實現功能: 設定顯示背景色(對工作區、文本有效)
//參數: Window - 工作窗口指針
// ColorSet - 背景顏色代碼,以16位存儲,格式為RRRRR-GGGGGG-BBBBB
// 當ColorSet=0x0000(COLOR_BLACK)時,背景色無效
//返回值: 無
//=============================================================
void TFT_SetBGColor(WIN_HANDLE Handle, unsigned short ColorSet)
{
STR_WINDOW *Window = g_WinList + Handle;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return;
Window->BGColor = ColorSet;
}
//=============================================================
//語法格式: unsigned short TFT_GetBGColor(STR_WINDOW *Window);
//實現功能: 獲取當前設定的背景色
//參數: Window - 工作窗口指針
//返回值: 背景顏色代碼,以16位存儲,格式為RRRRR-GGGGGG-BBBBB
//=============================================================
unsigned short TFT_GetBGColor(WIN_HANDLE Handle)
{
STR_WINDOW *Window = g_WinList + Handle;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return 0;
return Window->BGColor;
}
//=============================================================
//語法格式: void TFT_PutPixelAbsolute(STR_WINDOW *Window, short AbsX, short AbsY);
//實現功能: 在顯示緩沖區的指定位置畫點
//參數: Window - 工作窗口指針
// AbsX - 相對于屏幕的x坐標
// AbsY - 相對于屏幕的y坐標
//返回值: 無
//=============================================================
void TFT_PutPixelAbsolute(WIN_HANDLE Handle, short AbsX, short AbsY)
{
STR_WINDOW *Window = g_WinList + Handle;
unsigned short *pBuf;
short W, H;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return;
TFT_GetWorkBufSize(&W, &H);
if((AbsX>=0) && (AbsY>=0) && (AbsX < W)&&(AbsY < H))
{
pBuf = TFT_SelWorkBuf(-1) + AbsY * W + AbsX;
if(Window->Transparency==0)
*pBuf = Window->FGColor;
else
*pBuf = TFT_CalcTransparent(Window, *pBuf, Window->FGColor);
}
}
//=============================================================
//語法格式: void TFT_PutPixel(STR_WINDOW *Window, short x, short y);
//實現功能: 在工作區的指定位置畫點
//參數: Window - 工作窗口指針
// x - 相對于工作區的x坐標
// y - 相對于工作區的y坐標
//返回值: 無
//=============================================================
void TFT_PutPixel(WIN_HANDLE Handle, short x, short y)
{
STR_WINDOW *Window = g_WinList + Handle;
short AbsX, AbsY;
if((Handle < 0) || (Handle >= MAX_WINDOW) || (Window->Flag == 0))
return;
AbsX = Window->TLx+x;
AbsY = Window->TLy+y;
if(AbsX<Window->TLx || AbsX>Window->BRx)return;
if(AbsY<Window->TLy || AbsY>Window->BRy)return;
TFT_PutPixelAbsolute(Handle, AbsX, AbsY);
}
//=============================================================
//語法格式: void TFT_PutPixelLine(STR_WINDOW *Window, short line, COLOR ColorTab[])
//實現功能: 在工作區中根據顏色表繪制行
//參數: Window - 工作窗口指針
// x - 邏輯起始x坐標
// y - 邏輯行
// len - 繪制長度
// ColorTab - 顏色表
//返回值: 無
//=============================================================
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -