📄 uibig12.c
字号:
/* for wdc11x11.c */
#include <uiFont.h>
#include <uiBig12.h>
#include <uiUtility.h>
#include <uiBig12.res>
#ifdef GUI_FONTEX
#include <uiFontEx.h>
#endif
//unsigned short *guiGetBIG12Bitmap(const char *pCode)
unsigned short *guiGetBIG12Bitmap(const char *pCode)
{
unsigned int Index, IndexBase;
unsigned char FirstByte, SecondByte;
long int Offset, OffsetBase;
int FontWidth = 11 ;
int FontHeight = 11 ;
int BytesPerLine = ((FontWidth + 8 - 1) / 8) ;
int BytesPerGlyph = (BytesPerLine * FontHeight) ;
int FirstPart = (0x7E - 0x40 + 1) ;
int SecondPart = (0xFE - 0xA1 + 1) ;
int StandardSymbolGlyph = (0xA3 - 0xA1 + 1) ;
int MostFrequentlyUsedGlyph = (0xC6 - 0xA4 + 1) ;
int EtenExtendedGlyph = (0xC8 - 0xC7 + 1) ;
int SecondFrequentlyUsedGlyph = (0xF9 - 0xC9 + 1) ;
FirstByte = pCode[0];
SecondByte = pCode[1];
// Big5 To Common Index
// down arrow for menu, by zhang xue ping
// if ((FirstByte == uc1) && (SecondByte == uc2))
if ((FirstByte == 0xc6) && (SecondByte == 0xfe))
{
// return (unsigned short *)&WD_C_11x11Font[0];
return (unsigned short *)&WD_C_11x11Font[22*13974];
}
// by zhang xue ping
#ifdef GUI_FONTEX
if((FirstByte==0xC6) && (SecondByte>=0xA1))
return guiFontEx_GetBitmap(pCode);
#endif
// FirstByte的范围可以是0xA1到0xF9,SecondByte的范围可以是0x40到0x7E与0xA1到0xFE。
if ((FirstByte == 0xC6) && (SecondByte >= 0xA1)) // C6A1-C6FE: 94 Total
{ // 倚天外字集(文鼎未提供)
IndexBase = 0x8001;
SecondByte = SecondByte - 0xA1;
Index = IndexBase + SecondByte;
}
else
{
if ((FirstByte >= 0xA1) && (FirstByte <= 0xA3)) // A140-A3BF: 408 Total
{ // 标准符号
IndexBase = 0x8400;
FirstByte = FirstByte - 0xA1;
}
else if ((FirstByte >= 0xA4) && (FirstByte <= 0xC6))// A440-C67E: 5401 Total
{ // 常用字
IndexBase = 0x8800;
FirstByte = FirstByte - 0xA4;
}
else if ((FirstByte >= 0xC7) && (FirstByte <= 0xC8))// C740-C8D3: 271 Total
{ // 倚天外字集(文鼎未提供)
IndexBase = 0x805F;
FirstByte = FirstByte - 0xC7;
}
else if ((FirstByte >= 0xC9) && (FirstByte <= 0xF9))// C940-F9D5: 7652 Total
{ // F9D6-F9FE: 41 Total
IndexBase = 0x9D19; // 次常用字与表格符号
FirstByte = FirstByte - 0xC9;
}
else // Error
{
//return (long int) (-1);
return NULL;
}
if ((SecondByte >= 0x40) && (SecondByte <= 0x7E))
{
SecondByte = SecondByte - 0x40;
}
else if ((SecondByte >= 0xA1) && (SecondByte <= 0xFE))
{
SecondByte = SecondByte - 0xA1 + 0x3F;
}
else // Error
{
//return (-1);
return NULL;
}
Index = IndexBase + FirstByte * 0x9D + SecondByte;
}
// Common Index To File Offset
if ((Index >= 0x8001) && (Index <= 0x816D)) // 倚天外字集(文鼎未提供)
{
//return (-1);
return NULL;
}
else if ((Index >= 0x8400) && (Index <= 0x8597)) // 标准符号
{
OffsetBase = 0;
Offset = OffsetBase + (long int) (Index - 0x8400) * BytesPerGlyph;
}
else if ((Index >= 0x8800) && (Index <= 0x9D18)) // 常用字
{
OffsetBase = StandardSymbolGlyph * (FirstPart + SecondPart) * BytesPerGlyph;
Offset = OffsetBase + (long int) (Index - 0x8800) * BytesPerGlyph;
}
else if ((Index >= 0x9D19) && (Index <= 0xBB25)) // 次常用字与表格符号
{
OffsetBase = (StandardSymbolGlyph + MostFrequentlyUsedGlyph + EtenExtendedGlyph) *
(FirstPart + SecondPart) * BytesPerGlyph;
Offset = OffsetBase + (long int) (Index - 0x9D19) * BytesPerGlyph;
}
return (unsigned short *)&WD_C_11x11Font[Offset];
}
void guiShowBIG12Word(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);
_guiShowBIG12WordInView(&ViewRect, pCode, left, top, color, style);
}
short guiGetBIG12WordWidth(void)
{
return 12;
}
short guiGetBIG12WordHeight(void)
{
return 12;
}
// 增加对自定义汉字处理后的显示函数
void _guiShowBIG12WordInView(TRect *rect, const char *pCode,int x,int y,int color, int style)
{
unsigned short ch, sTemp;
int x0=x;
int y0=y+1;
int i;
int j;
int bkcolor, fgcolor;
char codeBuf[2];
unsigned short *pos, code;
bkcolor = (color&0x0000ff00)>>8;
fgcolor = color&0x000000ff;
pos=guiGetBIG12Bitmap(pCode);
if(!pos)
return;
codeBuf[0] = pCode[1];
codeBuf[1] = pCode[0];
code = *(unsigned short *)codeBuf;
if(style==FONT_TRANSPARENT)
{
for(i=0;i<11;i++)
{
x0=x;
sTemp = *pos++;
#ifdef __WIN32__
if((code>=0xc6a1)&&(code<0xc6fe))
{
ch = sTemp; // for make word by user
}
else
{
ch = sTemp<<8;
ch &= 0xff00;
ch |= ((sTemp>>8)&0x00ff);
}
#else
ch = sTemp;
#endif
for(j=0;j<11;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<11;i++)
{
x0 = x;
sTemp = *pos++;
#ifdef __WIN32__
if((code>=0xc6a1)&&(code<0xc6fe))
{
ch = sTemp; // for make word by user
}
else
{
ch = sTemp<<8;
ch &= 0xff00;
ch |= ((sTemp>>8)&0x00ff);
}
#else
ch = sTemp;
#endif
for(j=0;j<11;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++;
}
}
/*
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 + -