📄 uigb12.c
字号:
/*********************************************************************/
// 文 件 名: uiGB12.cpp
// 程序说明: 12点阵中文字处理模块
// 程序设计: 张学平
// 2001.10.23 设计完成 说明文档:R004-S232-0001
// 2002.03.10 增加自定义字的初始化和取得字符点阵的功能
// 程序审查: 宋军霞
// 2002.01.22 审查完成 说明文档:R004-S232-0001
// 项目编号: R004-S232
// 版 本: V1.0
// 版 权: Reality Plus Technology (ShenZhen) Co.,Ltd.
/*********************************************************************/
#include <uiFont.h>
#include <uiGB12.h>
#include <uiUtility.h>
#include <uiGB12.res>
#ifdef GUI_FONTEX
#include <uiFontEx.h>
#endif
void guiShowGB12Word(HNDL handle, const char *pCode,int x,int y, int color, int style)
{
TRect ViewRect;
int iRet, left, top;
int ViewLeft, ViewTop, ViewRight, ViewBottom;
iRet = _guiGetHandleView(handle, &ViewLeft, &ViewTop, &ViewRight, &ViewBottom);
if(iRet!=STATUS_OK)
return;
ViewRect.left = ViewLeft; ViewRect.top = ViewTop;
ViewRect.right = ViewRight; ViewRect.bottom = ViewBottom;
left = x;
top = y;
_guiConvertXY(handle, &left, &top);
_guiShowGB12WordInView(&ViewRect, pCode, left, top, color, style);
}
/*
// 增加对自定义汉字处理前的显示函数,该已函数已经通过测试
void _guiShowGB12WordInView(TRect *rect, const char *pCode,int x,int y,int color, int style)
{
int pos;
unsigned short ch;
int x0=x;
int y0=y;
int i;
int j;
unsigned char ch1,ch2;
int bkcolor, fgcolor;
bkcolor = (color&0x0000ff00)>>8;
fgcolor = color&0x000000ff;
ch1=pCode[0]-0xa1;
ch2=pCode[1]-0xa1;
if(ch1 < 0 || ch2 < 0)
return;
pos=ch1 * 94 + ch2;
if(pos < 0 || pos >= 8178)
return;
pos*=12;
if(style==FONT_TRANSPARENT)
{
for(i=0;i<12;i++)
{
x0=x;
ch = GB12_Data[pos];
for(j=0;j<12;j++)
{
if(ch & 0x8000)
if((x0>=rect->left)&&(x0<=rect->right)&&(y0>=rect->top)&&(y0<=rect->bottom))
displayDrawPixel(x0,y0,fgcolor);
ch<<=1;
x0++;
}
y0++;
pos++;
}
}
else
{
for(i=0;i<12;i++)
{
x0 = x;
ch = GB12_Data[pos];
for(j=0;j<12;j++)
{
if((x0>=rect->left)&&(x0<=rect->right)&&(y0>=rect->top)&&(y0<=rect->bottom))
{
if(ch & 0x8000)
displayDrawPixel(x0,y0,fgcolor);
else
displayDrawPixel(x0,y0,bkcolor);
}
ch<<=1;
x0++;
}
y0++;
pos++;
}
}
}
*/
short guiGetGB12WordWidth(void)
{
return 12;
}
short guiGetGB12WordHeight(void)
{
return 12;
}
unsigned short *guiGetGB12Bitmap(const char *pCode)
{
unsigned char ch1,ch2;
int pos;
ch1=pCode[0]-0xa1;
ch2=pCode[1]-0xa1;
/*tong
if(ch1 < 0 || ch2 < 0 )
return NULL;
*/
pos=ch1*94+ch2;
if(pos<8178 )
{
pos=pos*12;
return (unsigned short *)(&GB12_Data[pos]);
}
#ifdef GUI_FONTEX
return guiFontEx_GetBitmap(pCode);
#else
return NULL;
#endif
}
// 增加对自定义汉字处理后的显示函数
void _guiShowGB12WordInView(TRect *rect, const char *pCode,int x,int y,int color, int style)
{
unsigned short ch;
int x0=x;
int y0=y;
int i;
int j;
int bkcolor, fgcolor;
unsigned short *pos;
bkcolor = (color&0x0000ff00)>>8;
fgcolor = color&0x000000ff;
/*
if((pCode[0]==0xa1)&&(pCode[1]==0xaa))
{
i = 0;
}
*/
pos=guiGetGB12Bitmap(pCode);
if(!pos)
return;
if(style==FONT_TRANSPARENT)
{
for(i=0;i<12;i++)
{
x0=x;
ch = *pos++;
for(j=0;j<12;j++)
{
if(ch & 0x8000)
if((x0>=rect->left)&&(x0<=rect->right)&&(y0>=rect->top)&&(y0<=rect->bottom))
displayDrawPixel(x0,y0,fgcolor);
ch<<=1;
x0++;
}
y0++;
}
}
else
{
for(i=0;i<12;i++)
{
x0 = x;
ch = *pos++;
for(j=0;j<12;j++)
{
if((x0>=rect->left)&&(x0<=rect->right)&&(y0>=rect->top)&&(y0<=rect->bottom))
{
if(ch & 0x8000)
displayDrawPixel(x0,y0,fgcolor);
else
displayDrawPixel(x0,y0,bkcolor);
}
ch<<=1;
x0++;
}
y0++;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -