📄 uiclass.c
字号:
/******************************************************************/
/* Copyright (C) 2007 ROCK-CHIPS FUZHOU . All Rights Reserved. */
/*******************************************************************
File : uiclass.h
Desc : 窗口类通用调用
Author : GUI Develop Group.lzj
Date : 2007-08-10
Notes :
$Log: uiclass.c,v $
Revision 1.4 2008/06/19 04:43:20 Administrator
代码整理!
Revision 1.3 2008/06/03 02:21:24 Administrator
删除 C 库接口!
Revision 1.2 2008/05/30 10:08:33 Administrator
增加 wcscat() 函数!
Revision 1.1.1.1 2008/05/07 04:15:08 Administrator
no message
Revision 1.1.1.1 2008/03/06 13:29:09 Lingzhaojun
no message
Revision 1.11 2007/12/11 13:00:06 Huangshilin
no message
Revision 1.10 2007/11/23 09:56:18 Lingzhaojun
提交键盘锁代码
Revision 1.9 2007/11/23 07:32:05 Huangshilin
no message
Revision 1.8 2007/11/19 07:23:06 Xiexiuxin
谢 更改SID生成乱码
Revision 1.7 2007/11/19 02:39:19 Lingzhaojun
为加快刷屏速度,屏蔽所有UI半透效果
Revision 1.6 2007/10/26 07:57:49 Zhaojun
提交主界面修整
Revision 1.5 2007/10/16 04:03:25 Lingzhaojun
提交九宫格相关修改,加入游戏菜单,整理CVS音频库文件等
Revision 1.4 2007/10/11 13:26:24 Lingzhaojun
GUI增加九宫格控件
Revision 1.3 2007/10/08 04:02:23 Lingzhaojun
去除GUI的VC编译警告
Revision 1.2 2007/10/08 02:04:27 Lingzhaojun
GUI添加自动注释
*********************************************************************/
#include "include.h"
#include "uiclass.h"
void* GUIMalloc(size_t size)
{
void* Memget = NULL;
Memget = MALLOC(size);
if (Memget)
memset(Memget, 0, size);
return Memget;
}
/*----------------------------------------------------------------------
Name: DrawPicture
Desc: 画一张图片到逻辑屏
Params:
Return:
Author: lingzj
Date : 070830
----------------------------------------------------------------------*/
void DrawPicture(PicDescp Bmp)
{
//if((Bmp.BmpID<Min_BmpID)||(Bmp.BmpID>Max_BmpID))
// return ;
DrawBmpIdEx(Bmp.X, Bmp.Y, Bmp.BmpID, NULL, DSPM_Transp);
}
/*----------------------------------------------------------------------
Name: DrawPic
Desc: 画一张图片到逻辑屏
Params: x,y 坐标 id 图片的资源ID号
Author: LingZJ
Date : 070730
----------------------------------------------------------------------*/
void DrawPic(INT16S x, INT16S y, INT16U id)
{
// if((id<Min_BmpID)||(id>Max_BmpID))
// return ;
DrawBmpIdEx((INT16S)x, (INT16S)y, (INT16U)id, NULL, DSPM_Transp);
}
/*----------------------------------------------------------------------
Name: TxtboxRect
Desc: 画一行文本在一个窗口中,可以靠左,靠右,居中,靠顶,靠底
Params: win:窗口
TxtID:要画的文本ID,
Ft:字体
style :风格
Author: LingZJ
Date : 070730
----------------------------------------------------------------------*/
void TxtBox(WINDOW*win, UINT16 TxtID, FontType Font, TxtStyle style)
{
TxtRect Rect;
Rect.x = win->x;
Rect.y = win->y;
Rect.w = win->w;
Rect.h = win->h;
TxtBoxRect(win, TxtID, Font, &Rect , style);
}
/*----------------------------------------------------------------------
Name: TxtboxRect
Desc: 画一行文本到一个矩形中,可以靠左,靠右,居中,靠顶,靠底
Params: win:窗口
TxtID:要画的文本ID,
Ft:字体
Rect:范围
style :风格
Author: LingZJ
Date : 070730
----------------------------------------------------------------------*/
void TxtBoxRect(WINDOW*win, UINT16 TxtID, FontType Font, TxtRect*Rect , TxtStyle style)
{
WCHAR caption[100];
INT16U strPixLen, x, y, ft;
UINT32 Len;
Len = ResApiGetStringIDString(GuiDspGetWindowResProc(win , TxtID) , TxtID , caption , 100);
strPixLen = MeasureStringPixLen(caption , Font);
ft = (UINT16)Font;
switch (style)
{
case LeftStyle: /*靠左*/
x = Rect->x + ft / 2;
y = Rect->y + (Rect->h - ft) / 2;
break;
case RightStyle: /*靠右*/
x = (Rect->x + Rect->w) - (strPixLen + ft / 2);
y = Rect->y + (Rect->h - ft) / 2;
break;
case CenterStyle: /*居中*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + (Rect->h - ft) / 2;
break;
case TopStyle: /*靠上*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + ft / 2;
break;
case FootStyle: /*靠底*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + Rect->h - ft - 1;
break;
case LeanUpStyle: /*中偏上*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + (Rect->h / 3);
break;
case LeanDownStyle: /*中偏下*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + Rect->h / 2 + (Rect->h / 2 - ft) / 2 + ft;
break;
}
DrawStringEx(x , y , Rect->w, caption , Font , NULL , 0);
}
/*----------------------------------------------------------------------
Name: TxtboxEX
Desc: 画一行文本在一个窗口中,可以靠左,靠右,居中,靠顶,靠底
Params: win:窗口
TxtID:要画的文本ID,
Ft:字体
style :风格
Author: LingZJ
Date : 070730
----------------------------------------------------------------------*/
void TxtBoxEX(WINDOW*win, WCHAR *pTxt, FontType Font, TxtStyle style)
{
TxtRect Rect;
Rect.x = win->x;
Rect.y = win->y;
Rect.w = win->w;
Rect.h = win->h;
TxtBoxRectEX(pTxt, Font, &Rect , style);
}
/*----------------------------------------------------------------------
Name : TxtboxRectEX
Name: TxtboxRectEX
Desc: 画一行文本到一个矩形中,可以靠左,靠右,居中,靠顶,靠底
Params:
TxtID:要画的文本ID,
Ft:字体
Rect:范围
style :风格
Author: LingZJ
Date : 070730
----------------------------------------------------------------------*/
void TxtBoxRectEX(WCHAR *pTxt, FontType Font, TxtRect*Rect , TxtStyle style)
{
//WCHAR caption[100];
INT16U strPixLen, x, y, ft;
// UINT32 Len;
//Len=ResApiGetStringIDString( GuiDspGetWindowResProc( win ,TxtID) , TxtID , caption , 100 );
strPixLen = MeasureStringPixLen(pTxt , Font);
ft = (UINT16)Font;
switch (style)
{
case LeftStyle: /*靠左*/
x = Rect->x + ft / 2;
y = Rect->y + (Rect->h - ft) / 2;
break;
case RightStyle: /*靠右*/
x = (Rect->x + Rect->w) - (strPixLen + ft / 2);
y = Rect->y + (Rect->h - ft) / 2;
break;
case CenterStyle: /*居中*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + (Rect->h - ft) / 2;
break;
case TopStyle: /*靠上*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + ft / 2;
break;
case FootStyle: /*靠底*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + Rect->h - ft - 1;
break;
case LeanUpStyle: /*中偏上*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + (Rect->h / 3);
break;
case LeanDownStyle: /*中偏下*/
x = Rect->x + (Rect->w - strPixLen) / 2;
y = Rect->y + Rect->h / 2 + (Rect->h / 2 - ft) / 2 + ft;
break;
}
if ((x >= LCD_W) || (y >= LCD_H))
return;
DrawStringEx(x , y , Rect->w, pTxt , Font , NULL , 0);
}
/*----------------------------------------------------------------------
Name : WinGetTranStyle
Desc : 获取窗口属性对应的透明属性
Params:
Return:
Author: LingZJ
Date : 070830
----------------------------------------------------------------------*/
DispMode WinGetTranStyle(UINT32 winstyle)
{
DispMode TranspLevel = DSPM_Transp;
//暂时屏蔽半透效果
switch (winstyle&(WS_Transp | WS_TranspHalf))
{
case WS_TranspHalf: //所有颜色半透明
TranspLevel = DSPM_Transp4X8;
// TranspLevel=DSPM_Transp;
break;
case WS_Transp: //指定颜色全透明
TranspLevel = DSPM_Transp;
break;
case(WS_Transp|WS_TranspHalf): //窗口对所有颜色半透明,且对指定颜色全透
TranspLevel = DSPM_TranspMid;
// TranspLevel=DSPM_Transp;
break;
case 0:
TranspLevel = DSPM_Transp; //不透明
break;
}
return TranspLevel;
}
/*----------------------------------------------------------------------
Name : GetUnicodeLen
Desc : 获取unicode字符串长度
Params:
Return: 长度
Author: LingZJ
Date : 070830
----------------------------------------------------------------------*/
UINT16 GetUnicodeLen(WCHAR *p)
{
UINT16 Len = 0;
if (!p)return 0;
while (*p)
{
Len++;
p++;
}
return Len;
}
/*----------------------------------------------------------------------
Name : Unicodestrcat
Desc : 将UNICODE字符串U2添加到U1末尾
Params:
Return: 拷贝完毕后U1末尾的指针
Author: System Author
Date : 070830
----------------------------------------------------------------------*/
WCHAR *Unicodestrcat(WCHAR * U1, WCHAR * U2)
{
UINT16 Len = GetUnicodeLen(U2);
if (U2)
memcpy16(U1, U2, Len);
return (WCHAR *)(U1 + Len);
}
/*----------------------------------------------------------------------
Name : WinSendCommand
Desc : 向窗口发送command消息,交付用户处理
Params:
Return:
Author: LingZJ
Date : 070830
----------------------------------------------------------------------*/
UINT32 WinSendCommand(WINDOW*win, UINT16 EV)
{
if (win->style&WS_CHILDS)
return WindowSendMessage(win->Parent, WM_COMMAND, ((UINT32)(win->id)) << 16 | EV, win);
else
return WindowSendMessage(win, WM_COMMAND, ((UINT32)(win->id)) << 16 | EV, win);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -