📄 guimsg.c
字号:
yloc=200-Ylen_FFT[i];
color=(i/4)%4;
switch(color)
{
case 0:
FillRect(pScr, xloc, yloc, 8, ylen, &RGB_Red);
break;
case 1:
FillRect(pScr, xloc, yloc, 8, ylen, &RGB_Yellow);
break;
case 2:
FillRect(pScr, xloc, yloc, 8, ylen, &RGB_Green);
break;
case 3:
FillRect(pScr, xloc, yloc, 8, ylen, &RGB_Blue);
break;
}
}
}
//绘完波形直接清零
for(i=0;i<MAXSAMPLE_gui;i++)
{Ylen_FFT[i]=0;}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//进度条函数,PROGRESS_MAXLEN是进度条满格,tag表示进度,当tag == PROGRESS_MAXLEN时,
//进度条满格,很有用的东西,恩
int DrawControlProgress(HWND hwnd)
{
int iLeftScr,iTopScr;
if(hwnd)
{
GUI_FORM* pForm = (GUI_FORM*)(hwnd->pOwner);
SCR* pScr = (SCR*)(pForm->pScreen);
iLeftScr = pForm->left + hwnd->left;
iTopScr = pForm->top + hwnd->top;
//清除Progress所在区域,将区域颜色设为Progress的backcolor
FillRect(pScr,iLeftScr,iTopScr,hwnd->width,hwnd->height,&(hwnd->backcolor));
//是否visibled
if(hwnd->visibled)
{
DrawRect(pScr, iLeftScr,iTopScr,
hwnd->width , hwnd->height , &RGB_Black);
if(hwnd->tag>0)
{
if(hwnd->tag>PROGRESS_MAXLEN)
{
FillRect(pScr,iLeftScr,iTopScr,hwnd->width,hwnd->height,&RGB_Black);
}
else
//画进度条的函数
{
FillRect(pScr,iLeftScr,iTopScr,hwnd->width*hwnd->tag/PROGRESS_MAXLEN,hwnd->height,&RGB_Black);
}
}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//////////////////////////////////////////////////////////////////
//WinControlShow 是写完framebuffer后紧接着给LCD发消息
//直接显示一个控件
int WinControlShow(HWND handle)
{
GUI_FORM* pForm;
if(handle)
{
//如果handle的所在的form是visibled则进行下一步
//否则不进行处理。
pForm =(GUI_FORM*)(handle->pOwner);
if(pForm&&pForm->visibled)
{
switch(handle->type)
{
case GWC_BUTTON:
DrawControlButton(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_EDIT:
DrawControlEdit(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_INT_EDIT:
DrawControlEdit(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_FLOAT_EDIT:
DrawControlEdit(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_TEXT:
DrawControlText(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
//modified by zzm
//case GWC_GROUP:
//DrawControlGroup(handle);
//SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
//handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_PROGRESS:
DrawControlProgress(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_SORT_TEXT:
DrawControlSortText(handle);
//此处的宽度和高度与其他地方不同,不是hwnd-width 和hwnd->height,
//是固定死的,宽度=BMPW*MAXH_DEVICE,高度=BMPW
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, BMPW*MAXH_DEVICE, BMPW);
case GWC_HLINE:
DrawControlHLine(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
//handle->top+pForm->top, BMPW*MAXH_DEVICE, BMPW);
handle->top+pForm->top, handle->width, 1);
break;
case GWC_LINE:
DrawControlLine(handle);
if((handle->left > handle->width)&&(handle->top >handle->height) )
SendLcdMessage((SCR*)(pForm->pScreen),handle->width+pForm->left,
handle->height+pForm->top, handle->left+pForm->left, handle->top+pForm->top);
else if((handle->left < handle->width)&&(handle->top >handle->height))
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->height+pForm->top, handle->width+pForm->left, handle->top+pForm->top);
else if((handle->left < handle->width)&&(handle->top <handle->height))
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width+pForm->left, handle->height+pForm->top);
else if((handle->left > handle->width)&&(handle->top <handle->height))
SendLcdMessage((SCR*)(pForm->pScreen),handle->width+pForm->left,
handle->top+pForm->top, handle->left+pForm->left, handle->height+pForm->top);
break;
case GWC_VLINE:
DrawControlVLine(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, 1, handle ->height);
break;
case GWC_HOOK:
DrawControlHOOK(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top-10, handle->width+10, handle->height+10);
break;
case GWC_BMP:
DrawControlGroup(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_RECT:
DrawControlRect(handle);
SendLcdMessage((SCR*)(pForm->pScreen),handle->left+pForm->left,
handle->top+pForm->top, handle->width, handle->height);
break;
case GWC_CIRCLE:
DrawControlCircle(handle);
//SendLcdMessage((SCR*)(pForm->pScreen),150, handle->top-90, 550, 180);
break;
case GWC_CIRCLE_ALL:
DrawControlCircleAll(handle);
//SendLcdMessage((SCR*)(pForm->pScreen),150, handle->top-90, 550, 180);
break;
default:
//啥也不干
break;
}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//////////////////////////////////////////////////////////////////////
//WinControlShowWithoutUpdate 是写完framebuffer后不给LCD发消息
//仅仅改变framebuffer里的数据,而不发送LCD消息,这样也就不显示
int WinControlShowWithoutUpdate(HWND handle)
{
GUI_FORM* pForm;
if(handle)
{
//如果handle的所在的form是visibled则进行下一步
//否则不进行处理。
pForm =(GUI_FORM*)(handle->pOwner);
if(pForm&&pForm->visibled)
{
switch(handle->type)
{
case GWC_BUTTON:
DrawControlButton(handle);
break;
case GWC_EDIT:
DrawControlEdit(handle);
break;
case GWC_INT_EDIT:
DrawControlEdit(handle);
break;
case GWC_FLOAT_EDIT:
DrawControlEdit(handle);
break;
case GWC_TEXT:
DrawControlText(handle);
break;
//modified by zzm
//case GWC_GROUP:
//break;
case GWC_PROGRESS:
DrawControlProgress(handle);
break;
case GWC_SORT_TEXT:
DrawControlSortText(handle);
break;
case GWC_HLINE:
DrawControlHLine(handle);
break;
case GWC_VLINE:
DrawControlVLine(handle);
break;
case GWC_LINE:
DrawControlLine(handle);
break;
case GWC_HOOK:
DrawControlHOOK(handle);
break;
case GWC_BMP:
DrawControlGroup(handle);
//modified by zzm
//DrawControlBmp(handle);
break;
case GWC_CIRCLE:
DrawControlCircle(handle);
break;
case GWC_CIRCLE_ALL:
DrawControlCircleAll(handle);
break;
case GWC_RECT:
DrawControlRect(handle);
break;
default:
//啥也不干
break;
}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//直接切换到pScreen的下一个焦点处,当现在的焦点是最后一个控件时,则下一个焦点控件从第一个开始
GUI_WINCONTROL* SwitchToNextFocus(SCR* pScreen)
{
GUI_WINCONTROL* pCurrent;
GUI_WINCONTROL* pNext;
if((NULL != pScreen)&&(NULL != pScreen->formlink.pCurrentForm)&&
(NULL != pScreen->formlink.pCurrentForm->pFocusChild))
{
/*
当前焦点不能是canFoucus为FALSE的控件,
要切换到的下一个窗口也不能。
*/
pCurrent = pScreen->formlink.pCurrentForm->pFocusChild;
pNext = pCurrent;
do
{
pNext = pNext->pNext;
if(!pNext)
{
pNext = pScreen->formlink.pCurrentForm->pFirstChild;
}
}
//目的是找到下一个焦点控件
while(((!(pNext->visibled))||(!(pNext->canFocus)))&&(pNext !=pCurrent));
pScreen->formlink.pCurrentForm->pFocusChild = pNext;
WinControlShow(pCurrent); //重新刷新一遍先前的焦点控件
WinControlShow(pScreen->formlink.pCurrentForm->pFocusChild);
//刷新下一个焦点控件
return pNext;
}
else
return NULL;
}
//直接切换到pScreen的上一个焦点处,当现在的焦点是第一个控件时,则上一个焦点控件从最后一个开始
GUI_WINCONTROL* SwitchToPrevFocus(SCR* pScreen)
{
GUI_WINCONTROL* pCurrent;
GUI_WINCONTROL* pPrev;
if((NULL != pScreen)&&(NULL != pScreen->formlink.pCurrentForm)&&
(NULL != pScreen->formlink.pCurrentForm->pFocusChild))
{
/*
当前焦点不能是canFoucus为FALSE的控件,
要切换到的前一个窗口也不能。
*/
pCurrent = pScreen->formlink.pCurrentForm->pFocusChild;
pPrev = pCurrent;
do
{
pPrev = pPrev->pPrev;
if(!pPrev)
{
pPrev = pScreen->formlink.pCurrentForm->pLastChild;
}
}
//目的是找到上一个焦点控件
while(((!(pPrev->visibled))||(!(pPrev->canFocus)))&&(pPrev !=pCurrent));
pScreen->formlink.pCurrentForm->pFocusChild = pPrev;
WinControlShow(pCurrent);//重新刷新一遍先前的焦点控件
WinControlShow(pScreen->formlink.pCurrentForm->pFocusChild);
//刷新下一个焦点控件
return pPrev;
}
else
return NULL;
}
//直接切换到pForm的下一个焦点处并显示,当现在的焦点是最后一个控件时,则下一个焦点控件从第一个开始
GUI_WINCONTROL* FormSwitchToNextFocus(GUI_FORM* pForm)
{
GUI_WINCONTROL* pCurrent;
GUI_WINCONTROL* pNext;
if((NULL != pForm)&&(NULL != pForm->pFocusChild))
{
/*
当前焦点不能是canFoucus为FALSE的控件,
要切换到的下一个控件也不能。
*/
pCurrent = pForm->pFocusChild;
pNext = pCurrent;
do
{
pNext = pNext->pNext;
if(!pNext)
{
pNext = pForm->pFirstChild;
}
}
while(((!(pNext->visibled))||(!(pNext->canFocus)))&&(pNext !=pCurrent));
pForm->pFocusChild = pNext;
WinControlShow(pCurrent);
WinControlShow(pForm->pFocusChild);
//画焦点框
DrawRect((SCR*)(pForm->pScreen), pForm->left+pNext->left,pForm->top+pNext->top,pNext->width, pNext->height, &RGB_Black);
return pNext;
}
else
return NULL;
}
//直接切换到pForm的上一个焦点处并显示,当现在的焦点是第一个控件时,则上一个焦点控件从最后一个开始
GUI_WINCONTROL* FormSwitchToPrevFocus(GUI_FORM* pForm)
{
GUI_WINCONTROL* pCurrent;
GUI_WINCONTROL* pPrev;
if((NULL != pForm)&& (NULL != pForm->pFocusChild))
{
/*
当前焦点不能是canFoucus为FALSE的控件,
要切换到的前一个控件也不能。
*/
pCurrent = pForm->pFocusChild;
pPrev = pCurrent;
do
{
pPrev = pPrev->pPrev;
if(!pPrev)
{
pPrev = pForm->pLastChild;
}
}
while(((!(pPrev->visibled))||(!(pPrev->canFocus)))&&(pPrev !=pCurrent));
pForm->pFocusChild = pPrev;
WinControlShow(pCurrent);
WinControlShow(pForm->pFocusChild);
//画焦点框
DrawRect((SCR*)(pForm->pScreen), pForm->left+pPrev->left,pForm->top+pPrev->top,pPrev->width, pPrev->height, &RGB_Black);
return pPrev;
}
else
return NULL;
}
//全局变量bMessage表明当前是否有阻塞式messagebox存在
//FALSE = 无TRUE= 有,在MsgBox函数中要把它置为TRUE,在相应
//的消息预处理函数PreProcessMsg中,在相应的按键消息处理
//中将其置为FALSE.
int MsgBox(SCR* pScr,const char* pText,uint iType)
{
if((pScr)&&(pText)&&(!bMessage))
{
gfMessageBox.pScreen = pScr;
strcpy(gwMB_Text.text,pText);
if(iType&MB_OK)
gwMB_OK.visibled = TRUE;
else
gwMB_OK.visibled = FALSE;
if(iType&MB_CANCEL)
gwMB_CANCEL.visibled = TRUE;
else
gwMB_CANCEL.visibled = FALSE;
FormShow(&gfMessageBox);
//画焦点框
DrawRect(pScr, gfMessageBox.left+gfMessageBox.pFocusChild->left,
gfMessageBox.top+gfMessageBox.pFocusChild->top,
gfMessageBox.pFocusChild->width,
gfMessageBox.pFocusChild->height, &RGB_Black);
bMessage = TRUE;
return GUI_SUCCESS;
}
else
return ERR_POINTER_EMPTY;
}
//返回pScr的当前的Form
GUI_FORM* GetCurrentForm(SCR* pScr)
{
if(pScr)
return pScr->formlink.pCurrentForm;
else
return NULL;
}
//返回pScr的当前的焦点控件
GUI_WINCONTROL* GetCurrentFocus(SCR* pScr)
{
if(pScr)
return pScr->formlink.pCurrentForm->pFocusChild;
else
return NULL;
}
//这个函数的功能是,在x,y座标处画一个点,颜色为pRgb,不更新pScreen的framebuffer
int DrawDot_IO(SCR* pScreen,uint x,uint y,RGB* pRgb)
{
uint iNum;
if((pScreen!=NULL)&&(pRgb!=NULL))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -