📄 uiscrolltext.c
字号:
DrawBmpIdEx(win->x, win->y, ScrollText->ScrollTextBID, &BkRect, DSPM_Transp);
else if (win->BmpID)
DrawBmpIdEx(win->x, win->y, win->BmpID, &BkRect, DSPM_Transp);
}
rect.x = ScrollText->ScrollRect.x;
rect.y = ScrollText->ScrollRect.y;
rect.h = ScrollText->ScrollRect.h;
pDst = gGuiDspLcdLogic + win->y * LCD_W + win->x;
wtemp = gGuiDspBmpHead.w;
TranspColorTemp = SetTranspColor(COLOR_BLUE);
rect.w = win->w;
if (ScrollText->ScrollTextStatus != NoScroll)
{
if (win->style&WES_ScrollLeft)
{
pSrc = ScrollText->pScrollPic + ScrollText->ScrollTextCnt;
gGuiDspBmpHead.w = ScrollText->ScrollRect.w;
}
if (win->style&WES_ScrollRight)
{
pSrc = ScrollText->pScrollPic + ScrollText->ScrollRect.w - rect.w - ScrollText->ScrollTextCnt;
gGuiDspBmpHead.w = ScrollText->ScrollRect.w;
}
if (win->style&WES_ScrollLeftRight)
{
if (ScrollText->ScrollTextFlag == 0)
pSrc = ScrollText->pScrollPic + ScrollText->ScrollTextCnt;
else
pSrc = ScrollText->pScrollPic + ScrollText->ScrollRect.w - rect.w - ScrollText->ScrollTextCnt;
gGuiDspBmpHead.w = ScrollText->ScrollRect.w;
}
if (win->style&WES_ScrollRightLeft)
{
if (ScrollText->ScrollTextFlag == 0)
pSrc = ScrollText->pScrollPic + ScrollText->ScrollRect.w - rect.w - ScrollText->ScrollTextCnt;
else
pSrc = ScrollText->pScrollPic + ScrollText->ScrollTextCnt;
gGuiDspBmpHead.w = ScrollText->ScrollRect.w;
}
}
else
{
INT16U strPixLen;
strPixLen = MeasureStringPixLen(ScrollText->pScrollTxt , ScrollText->ScrollRect.h);
rect.w = ScrollText->ScrollRect.w;
pSrc = ScrollText->pScrollPic;
gGuiDspBmpHead.w = ScrollText->ScrollRect.w;
if (win->style&WES_NoScrollRight)
pDst = gGuiDspLcdLogic + win->y * LCD_W + win->x + (win->w - strPixLen);
else if (win->style&WES_NoScrollMiddle)
pDst = gGuiDspLcdLogic + win->y * LCD_W + win->x + (win->w - strPixLen) / 2;
else
pDst = gGuiDspLcdLogic + win->y * LCD_W + win->x;
}
if (win->y < gScreenUpdateY0)
gScreenUpdateY0 = win->y;
if (win->y + win->h > gScreenUpdateY1)
gScreenUpdateY1 = win->y + win->h;
if (win->x < gScreenUpdateX0)
gScreenUpdateX0 = win->x;
if (win->x + win->w > gScreenUpdateX1)
gScreenUpdateX1 = win->x + win->w;
IGuiDspBmpPaint(pDst, pSrc, &rect, DSPM_Transp);
gGuiDspBmpHead.w = wtemp;
SetTranspColor(TranspColorTemp);
//else
//{
// INT16U strPixLen;
//strPixLen = MeasureStringPixLen( ScrollText->pScrollTxt , ScrollText->ScrollRect.h);
// DrawStringEx(win->x, win->y, win->w, ScrollText->pScrollTxt, Font16X16,&(ScrollText->color), 0);
// }
//DrawPicInMemery(win->x,win->y,ScrollText->pScrollPic,&ScrollText->ScrollRect,DSPM_Transp);
//DrawStringEx(0, 0,ScrollText->ScrollRect.w, ScrollText->pScrollTxt,ScrollText->Font, &(ScrollText->color), 0);
WIN_CLEARPAIT(win);
return TRUE;
}
/*----------------------------------------------------------------------
Name: ScrollTextSetTxt
Desc: 画一行文本在一个窗口中,可以靠左,靠右,居中,靠顶,靠底
Params: win:窗口
Author: Eddie CF
----------------------------------------------------------------------*/
UINT32 ScrollTextSetTxt(WINDOW* win , WMPARAM wParam, WLPARAM lParam)
{
SCORLLTEXT *ScrollText = (SCORLLTEXT*)win->Data;
LCD_RGBDATA *pLcdDataTmp;
WCHAR *PScrollTxtTmp = (WCHAR*)wParam;
if (ScrollText->ScrollTimer)
{
WinStopTimer(ScrollText->ScrollTimer);
ScrollText->ScrollTimer = 0;
}
LOGICUPDATE_DISABLE();
if (win->style&WS_ACTIVE)
win->style &= ~WS_ACTIVE;
if (ScrollText->pScrollPic)
{
FREE(ScrollText->pScrollPic);
//TR("ScroText Free OK,ptr=0X%x",ScrollText->pScrollPic );
ScrollText->pScrollPic = NULL;
}
ScrollText->ScrollRect.w = MeasureStringPixLen( PScrollTxtTmp , ScrollText->Font);
ScrollText->ScrollRect.h = ScrollText->Font;
ScrollText->ScrollTextSize = ScrollText->ScrollRect.w * ScrollText->Font * sizeof(LCD_RGBDATA);
if (ScrollText->ScrollTextSize)
pLcdDataTmp = (LCD_RGBDATA*)MALLOC(ScrollText->ScrollTextSize);
//TR("ScroText Malloc OK,ptr=0X%x", ScrollText->pScrollPic);
if ( !pLcdDataTmp )
{
LOGICUPDATE_ENABLE();
return FALSE;
}
memset32( pLcdDataTmp , COLOR_BLUE, (ScrollText->ScrollRect.w*ScrollText->Font));
DrawString2Ram(0, 0, ScrollText->ScrollRect.w, PScrollTxtTmp, ScrollText->Font, &(ScrollText->color), 0, pLcdDataTmp);
ScrollText->ScrollTextCnt = 0;
ScrollText->ScrollTextHoldTick = 0;
if (ScrollText->ScrollRect.w > win->w)
{
ScrollText->ScrollTextStatus = ScrollBegin;
ScrollText->ScrollTimer = WinStartTimer(win, 24);
}
else
ScrollText->ScrollTextStatus = NoScroll;
ScrollText->pScrollTxt = PScrollTxtTmp;
ScrollText->pScrollPic = pLcdDataTmp;
if (win->style&WS_CHILDS)
win->style |= WS_ACTIVE;
WindowInvalidateWindow(win);
LOGICUPDATE_ENABLE();
return TRUE;
}
/*----------------------------------------------------------------------
Name: ScrollTextSetColor
Desc: 画一行文本在一个窗口中,可以靠左,靠右,居中,靠顶,靠底
Params: win:窗口
Author: Eddie CF
----------------------------------------------------------------------*/
UINT32 ScrollTextSetColor(WINDOW* win , WMPARAM wParam, WLPARAM lParam)
{
SCORLLTEXT *ScrollText = (SCORLLTEXT*)win->Data;
ColorDesc *Color = (ColorDesc*)(wParam);
//080512,huangsl,增加判断
//由于可能存在没有设置文本之前首先设置 颜色,所有下面的判断要去掉.
//
if ( /*ScrollText->pScrollTxt == NULL || ScrollText->pScrollPic == NULL || */
Color == NULL || ScrollText->color.forward == Color->forward )
return TRUE;
ScrollText->color.forward = Color->forward;
if( ScrollText->pScrollPic )
{
LOGICUPDATE_DISABLE();
memset32(ScrollText->pScrollPic, COLOR_BLUE, (ScrollText->ScrollRect.w*ScrollText->Font));
DrawString2Ram(0, 0, ScrollText->ScrollRect.w, ScrollText->pScrollTxt, ScrollText->Font, &(ScrollText->color), 0, ScrollText->pScrollPic);
ScrollText->ScrollTextCnt = 0;
WindowInvalidateWindow(win);
LOGICUPDATE_ENABLE();
}
return TRUE;
}
/*----------------------------------------------------------------------
Name: ScrollTextSetFont
Desc: 设置滚动字符串的字体
Params: win:窗口
Author: Eddie CF
----------------------------------------------------------------------*/
UINT32 ScrollTextSetFont(WINDOW* win , WMPARAM wParam, WLPARAM lParam)
{
SCORLLTEXT *ScrollText = (SCORLLTEXT*)win->Data;
//080512,huangsl,增加判断
if (/*ScrollText->pScrollTxt == NULL || ScrollText->pScrollPic == NULL || */
ScrollText->Font == (FontType)wParam )
return TRUE;
ScrollText->Font = (FontType)wParam;
if( ScrollText->pScrollPic )
{
LOGICUPDATE_DISABLE();
memset32(ScrollText->pScrollPic, COLOR_BLUE, (ScrollText->ScrollRect.w*ScrollText->Font));
DrawString2Ram(0, 0, ScrollText->ScrollRect.w, ScrollText->pScrollTxt, ScrollText->Font, &(ScrollText->color), 0, ScrollText->pScrollPic);
ScrollText->ScrollTextCnt = 0;
WindowInvalidateWindow(win);
LOGICUPDATE_ENABLE();
}
return TRUE;
}
/*----------------------------------------------------------------------
Name: ScrollTextSetPic
Desc: 设置滚动字符串的字体
Params: win:窗口
Author: Eddie CF
----------------------------------------------------------------------*/
UINT32 ScrollTextSetPic(WINDOW* win , WMPARAM wParam, WLPARAM lParam)
{
SCORLLTEXT *ScrollText = (SCORLLTEXT*)win->Data;
//INT16U mode = (INT16U*)&lParam
ScrollText->ScrollTextBID = (INT16U)wParam;
ScrollText->ScrollTextDispMode = *(DispMode*)lParam;
return TRUE;
}
/*----------------------------------------------------------------------
Name: ScrollSetSpeed
Desc: 设置滚动字符串的速度
Params: win:窗口
Author: Eddie CF
----------------------------------------------------------------------*/
UINT32 ScrollSetSpeed(WINDOW* win , WMPARAM wParam, WLPARAM lParam)
{
SCORLLTEXT *ScrollText = (SCORLLTEXT*)win->Data;
if (ScrollText->ScrollTimer)
{
WinStopTimer(ScrollText->ScrollTimer);
ScrollText->ScrollTimer = 0;
}
ScrollText->ScrollTextCnt = 0;
WindowInvalidateWindow(win);
if (ScrollText->ScrollRect.w > win->w)
ScrollText->ScrollTimer = WinStartTimer(win, wParam);
return TRUE;
}
BEGIN_CHILDMESSAGE_MAP(WinScrollTextMap , CW_TYPE_ScrollText)
ON_MESSAGE(WM_PAINT , ScrollTextPaint)
ON_MESSAGE(WM_DESTROY , ScrollTextDestroy)
ON_MESSAGE(WM_CREATE, ScrollTextCreate)
ON_MESSAGE(WM_SetTxt, ScrollTextSetTxt)
ON_MESSAGE(WM_SetColor, ScrollTextSetColor)
ON_MESSAGE(WM_SetFont, ScrollTextSetFont)
ON_MESSAGE(WM_SetPic, ScrollTextSetPic)
ON_MESSAGE(WM_TIMER, ScrollTextTimer)
ON_MESSAGE(WM_StopScroll, ScrollStopScroll)
ON_MESSAGE(WM_SetSpeed, ScrollSetSpeed)
//ON_MESSAGE(WM_COMMAND, ScrollTextCommand)
//ON_MESSAGE(WM_TOUCH , ScrollTextTouch)
//ON_MESSAGE(WM_SetPercent , ScrollTextSetPercent)
//ON_MESSAGE(WM_SetScrollLen, ScrollTextSetScrollLen)
//ON_MESSAGE(WM_GetPercent, GetScrollPercent)
END_MESSAGE_MAP()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -