📄 guimsg.c
字号:
}
while((GF_NOT_SWITCH == pForm->type)&&(pForm != pScr->formlink.pCurrentForm));
pScr->formlink.pCurrentForm->visibled = FALSE;
pScr->formlink.pCurrentForm = pForm;
FormShow(pForm);
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//注意控件的坐标是针对form的左上角的坐标,
//因此要加上form的起始坐标
int DrawControlButton(HWND hwnd)
{
int iLeftScr,iTopScr;
int i;
if(hwnd)
{
GUI_FORM* pForm = (GUI_FORM*)(hwnd->pOwner);
SCR* pScr = (SCR*)(pForm->pScreen);
iLeftScr = pForm->left + hwnd->left;
iTopScr = pForm->top + hwnd->top;
//清除Button所在区域,将区域颜色设为Button的backcolor
FillRect(pScr,iLeftScr,iTopScr,hwnd->width,hwnd->height,&(hwnd->backcolor));
//是否visibled
if(hwnd->visibled)
{
//要把focus的地方留出来
DrawRect(pScr, iLeftScr+GUI_FOCUS_GAP,iTopScr+GUI_FOCUS_GAP,
hwnd->width -2*GUI_FOCUS_GAP, hwnd->height -2*GUI_FOCUS_GAP, &RGB_Black);
//画阴影部分
for(i=1;i<=GUI_WINCONTROL_SHAPE;i++)
{
DrawHLine(pScr, iLeftScr+GUI_FOCUS_GAP, iTopScr+hwnd->height-GUI_FOCUS_GAP-i,
hwnd->width -2*GUI_FOCUS_GAP, &RGB_Black);
DrawVLine(pScr, iLeftScr+hwnd->width-GUI_FOCUS_GAP-i,
iTopScr+GUI_FOCUS_GAP, hwnd->height - 2*GUI_FOCUS_GAP, &RGB_Black);
}
DrawText(pScr,hwnd->alligntype,&(hwnd->fontcolor), hwnd->fontsize, iLeftScr+GUI_FOCUS_GAP+1,
iTopScr+GUI_FOCUS_GAP+1, iLeftScr+hwnd->width-GUI_FOCUS_GAP - 1,
iTopScr+hwnd->height-GUI_FOCUS_GAP-1, hwnd->text,0);
//判断该button是否是焦点,如果是Focus ,外面画个框
if(hwnd ==( pScr->formlink.pCurrentForm->pFocusChild))
{
DrawRect(pScr, iLeftScr,iTopScr, hwnd->width, hwnd->height, &RGB_Black);
DrawRect(pScr, iLeftScr+1,iTopScr+1,hwnd->width-2, hwnd->height-2, &RGB_Black);
}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
// (SCR * pScreen, uint x, uint y, uint iWidth, uint iHeight, RGB * pRgb)
}
//可以编辑的控件显示
int DrawControlEdit(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;
//清除Edit所在区域,将区域颜色设为Edit的backcolor
FillRect(pScr,iLeftScr,iTopScr,hwnd->width,hwnd->height,&(hwnd->backcolor));
//是否visibled
if(hwnd->visibled)
{
//要把focus的地方留出来
//DrawRect(pScr, iLeftScr+GUI_FOCUS_GAP,iTopScr+GUI_FOCUS_GAP,
// hwnd->width -2*GUI_FOCUS_GAP, hwnd->height -2*GUI_FOCUS_GAP, &RGB_Black);
//画阴影部分
/*
for(i=1;i<=GUI_WINCONTROL_SHAPE;i++)
{
DrawHLine(pScr, iLeftScr+GUI_FOCUS_GAP, iTopScr+hwnd->height-GUI_FOCUS_GAP-i,
hwnd->width -2*GUI_FOCUS_GAP, &rgbEdge);
DrawVLine(pScr, iLeftScr+hwnd->width-GUI_FOCUS_GAP-i,
iTopScr+GUI_FOCUS_GAP, hwnd->height - 2*GUI_FOCUS_GAP, &rgbEdge);
}
*/
//判断该Edit是否是焦点,如果是Focus ,外面画个框,并将需要第几个字反色
//传递给DrawText
if(hwnd ==( pScr->formlink.pCurrentForm->pFocusChild))
{
DrawText(pScr,hwnd->alligntype,&(hwnd->fontcolor), hwnd->fontsize, iLeftScr+GUI_FOCUS_GAP+1,
iTopScr+GUI_FOCUS_GAP+1, iLeftScr+hwnd->width-GUI_FOCUS_GAP-1,
iTopScr+hwnd->height-GUI_FOCUS_GAP-1, hwnd->text,hwnd->tag+1);
DrawRect(pScr, iLeftScr,iTopScr, hwnd->width, hwnd->height, &RGB_Black);
DrawRect(pScr, iLeftScr+1,iTopScr+1,hwnd->width-2, hwnd->height-2, &RGB_Black);
}
else
{
//如果不是焦点,则不需要反色
DrawText(pScr,hwnd->alligntype,&(hwnd->fontcolor), hwnd->fontsize, iLeftScr+GUI_FOCUS_GAP+1,
iTopScr+GUI_FOCUS_GAP+1, iLeftScr+hwnd->width-GUI_FOCUS_GAP-1,
iTopScr+hwnd->height-GUI_FOCUS_GAP-1, hwnd->text,0);
}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//文字框控件显示
int DrawControlText(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;
//清除Text所在区域,将区域颜色设为Edit的backcolor
FillRect(pScr,iLeftScr,iTopScr,hwnd->width,hwnd->height,&(hwnd->backcolor));
//是否visibled
if(hwnd->visibled)
{
//text控件中如果tag不为零,则画框,否则不画框
if(hwnd->tag == ALLREVERSE)
{
DrawText(pScr,hwnd->alligntype,&(hwnd->fontcolor), hwnd->fontsize, iLeftScr+1,
iTopScr+1, iLeftScr+hwnd->width-1,
iTopScr+hwnd->height-1, hwnd->text,ALLREVERSE);
}
else
{
if(hwnd->tag)
DrawRect(pScr, iLeftScr,iTopScr, hwnd->width, hwnd->height, &RGB_Black);
DrawText(pScr,hwnd->alligntype,&(hwnd->fontcolor), hwnd->fontsize, iLeftScr+1,
iTopScr+1, iLeftScr+hwnd->width-1,
iTopScr+hwnd->height-1, hwnd->text,0);
}
/*
DrawText(pScr,hwnd->alligntype,&(hwnd->fontcolor), hwnd->fontsize, iLeftScr+GUI_FOCUS_GAP+1,
iTopScr+GUI_FOCUS_GAP+1, iLeftScr+hwnd->width-GUI_FOCUS_GAP-1,
iTopScr+hwnd->height-GUI_FOCUS_GAP-1, hwnd->text);
*/
//判断该text是否是焦点,如果是Focus ,外面画个框
//Text控件一般不用focus
if(hwnd ==( pScr->formlink.pCurrentForm->pFocusChild))
{
DrawRect(pScr, iLeftScr,iTopScr, hwnd->width, hwnd->height, &RGB_Black);
}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//绘制位图控件
int DrawControlBmp(HWND hwnd)
{
int iLeftScr,iTopScr;
int thetag;
GUI_FORM* pForm;
SCR* pScr;
unsigned char (*pBmp)[2];
if(hwnd)
{
switch(hwnd->tag)
{
case SET_OFF:
pBmp=BmpOff;
break;
case SET_ON:
pBmp=BmpOn;
break;
case GWC_RES:
pBmp=BmpRes;
break;
default:
//pBmp=bmpicon;
break;
};
pForm = (GUI_FORM*)(hwnd->pOwner);
pScr = (SCR*)(pForm->pScreen);
iLeftScr = pForm->left + hwnd->left;
iTopScr = pForm->top + hwnd->top;
//是否visibled
if(hwnd->visibled)
{
// FillRect(pScr, iLeftScr+1, iTopScr+1, hwnd->width,hwnd->height, &hwnd->backcolor);
FillRect(pScr,iLeftScr+1,iTopScr+1,hwnd->width,hwnd->height,&(hwnd->backcolor));
DrawBmp(pScr,iLeftScr+1, iTopScr+1, &RGB_Black, pBmp);
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//画垂直线
int DrawControlRect(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;
if(hwnd->visibled)
{
FillRect(pScr,iLeftScr,iTopScr,hwnd->width,hwnd->height,&(hwnd->backcolor));
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
int DrawControlVLine(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;
FillRect(pScr,iLeftScr,iTopScr,hwnd->width,hwnd->height,&(hwnd->backcolor));
//是否visibled
if(hwnd->visibled)
{
DrawVLine(pScr, iLeftScr,iTopScr, hwnd->height , &RGB_Black);
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
//画水平线
int DrawControlHLine(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;
//是否visibled
if(hwnd->visibled)
{
DrawHLine(pScr, iLeftScr,iTopScr,hwnd->width, &RGB_Black);
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
int DrawLine(SCR* pScreen,int x1,int y1,int x2,int y2,RGB* pRgb)
{
int x3,y3;
unsigned int i;
float k,A;
k = (float)(y2-y1)/(x2-x1);
A = (float)(y1*x2-y2*x1)/(x2-x1);
if(x1 == x2)
{
if(y1<y2)
{
y3 = y2;
y2 = y1;
y1 =y3;
}
for(i=y2;i<=y1;i++)
DrawDot(pScreen,x1,i,pRgb);
return;
}
if(y1 == y2)
{
if(x1<x2)
{
x3 = x2;
x2 = x1;
x1 =x3;
}
for(i=x2;i<=x1;i++)
DrawDot(pScreen,i,y1,pRgb);
return;
}
if(x1<x2)
{
x3 = x2;
x2 = x1;
x1 =x3;
}
if(y1<y2)
{
y3 = y2;
y2 = y1;
y1 =y3;
}
if((x1 - x2)>=(y1 - y2))
{
for(i=x2;i<=x1;i++)
DrawDot(pScreen,i,k*i+A,pRgb);
}
else
{
A = A/k;
k = 1/k;
for(i=y2;i<=y1;i++)
DrawDot(pScreen,k*i-A,i,pRgb);
}
}
int DrawControlLine(HWND hwnd)
{
if(hwnd)
{
GUI_FORM* pForm = (GUI_FORM*)(hwnd->pOwner);
SCR* pScr = (SCR*)(pForm->pScreen);
//是否visibled
if(hwnd->visibled)
{
//DrawHLine(pScr, iLeftScr,iTopScr,hwnd->width, &RGB_Black);
DrawLine(pScr,pForm->left + hwnd->left,pForm->top + hwnd->top,
pForm->left + hwnd->width,pForm->top + hwnd->height,&RGB_Black);
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
int DrawControlHOOK(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;
//是否visibled
if(hwnd->visibled)
{
if(hwnd->valuecount == 0)
{
DrawLine(pScr,iLeftScr,iTopScr+hwnd->height /2,
iLeftScr + hwnd->width/2,iTopScr+hwnd->height,&RGB_LightBlue);
DrawLine(pScr,iLeftScr + hwnd->width/2,iTopScr+hwnd->height,
iLeftScr + hwnd->width*3/2,iTopScr-hwnd->height /2,&RGB_LightBlue);
}
else if(hwnd->valuecount == 1)
{
DrawLine(pScr,iLeftScr,iTopScr+hwnd->height /2,
iLeftScr + hwnd->width/2,iTopScr+hwnd->height,&RGB_Black);
DrawLine(pScr,iLeftScr + hwnd->width/2,iTopScr+hwnd->height,
iLeftScr + hwnd->width*3/2,iTopScr-hwnd->height /2,&RGB_Black);
}
DrawRect(pScr, iLeftScr,iTopScr,
hwnd->width , hwnd->height , &RGB_Black);
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
int DrawControlSortText(HWND hwnd)
{
int iLeftScr,iTopScr;
int i,j;
if(hwnd)
{
GUI_FORM* pForm = (GUI_FORM*)(hwnd->pOwner);
SCR* pScr = (SCR*)(pForm->pScreen);
iLeftScr = pForm->left + hwnd->left;
iTopScr = pForm->top + hwnd->top;
//清除控件所在区域,将区域颜色设为该控件的backcolor
FillRect(pScr,iLeftScr,iTopScr,BMPW*MAXH_DEVICE,BMPW,&(hwnd->backcolor));
//是否visibled
if(hwnd->visibled)
{
for(i = 0; i< MAXH_DEVICE; i++)
{
j = i%10;
WriteAsci(pScr, &(hwnd->fontcolor), hwnd->fontsize, iLeftScr+i*BMPW, iTopScr, j+48);
}
}
}
else
return ERR_POINTER_EMPTY;
return GUI_SUCCESS;
}
int DrawControlGroup(HWND hwnd)
{
int iLeftScr,iTopScr;
int i,j,color=0;
uint ylen,xloc,yloc;
if(hwnd)
{
GUI_FORM* pForm = (GUI_FORM*)(hwnd->pOwner);
SCR* pScr = (SCR*)(pForm->pScreen);
//iLeftScr = pForm->left + hwnd->left;
//iTopScr = pForm->top + hwnd->top;
//是否visibled
if(hwnd->visibled)
{ //清除上次的谐波分析波形
for(i=1;i<180;i++)
{
for(j=1;j<520;j++)
{
DrawDot(pScr, hwnd->left+j, hwnd->top+i, &RGB_LightBlue);
}
}
//绘新的谐波分析波形
for(i=0;i<MAXSAMPLE_gui;i++)
{
if(i%4==0&&i<=256)//i=0,4,8,12,16,20,24,28,32......
{
ylen=Ylen_FFT[i];
//if(ylen>180)
// {ylen=180;}
//xloc=i*4+200;
xloc=i*2+200;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -