📄 guichar.c
字号:
}
/*
************************************************************
*
* GL/CL DispChar
*
************************************************************
*/
void GL_DispChar(U16 c) {
/* check for control characters */
if (c == '\n') {
GUI_DispNextLine();
} else {
if (c != '\r') {
GUI_Context.pAFont->pfDispChar(c);
}
}
}
#if (GUI_WINSUPPORT)
/* Note on usage of this routine:
If at all possible, try to avoid using this, since
every call will invoke the window manager. If possible,
use the string routines.
*/
static void CL_DispChar(U16 c) {
GUI_RECT r;
WM_ADDORG(GUI_Context.DispPosX, GUI_Context.DispPosY);
r.x1 = (r.x0 = GUI_Context.DispPosX) + GUI_GetCharDistX(c)-1;
r.y1 = (r.y0 = GUI_Context.DispPosY) + GUI_GetFontSizeY()-1;
WM_ITERATE_START(&r) {
GL_DispChar(c);
if (c != '\n')
GUI_Context.DispPosX = r.x1 + 1;
} WM_ITERATE_END();
WM_SUBORG(GUI_Context.DispPosX,GUI_Context.DispPosY);
}
#endif
void GUI_DispChar(U16 c) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
CL_DispChar(c);
#else
GL_DispChar(c);
#endif
GUI_UNLOCK();
}
/*
************************************************************
*
* GL/CL DispCharAt
*
************************************************************
*/
void GUI_DispCharAt(U16 c, I16P x, I16P y) {
GUI_LOCK();
GUI_Context.DispPosX =x;
GUI_Context.DispPosY =y;
#if (GUI_WINSUPPORT)
CL_DispChar(c);
#else
GL_DispChar(c);
#endif
GUI_UNLOCK();
}
/*
************************************************************
*
* GUI_SetFont
*
************************************************************
*/
const GUI_FONT* GUI_SetFont(const GUI_FONT* pNewFont) {
const GUI_FONT * pOldFont = GUI_Context.pAFont;
GUI_LOCK();
if (pNewFont)
GUI_Context.pAFont = pNewFont;
GUI_UNLOCK();
return pOldFont;
}
/*
************************************************************
* *
* Set the write position *
* *
************************************************************
Sets the write position. The routines routine 1 if it is clear that
the current write position is in an area outside the current window
and will therefor not be written.
*/
static char _GotoY(int y) {
GUI_Context.DispPosY = y;
return 0;
}
static char _GotoX(int x) {
GUI_Context.DispPosX = x;
return 0;
}
char GUI_GotoY(int y) {
char r;
GUI_LOCK();
r = _GotoY(y);
GUI_UNLOCK();
return r;
}
char GUI_GotoX(int x) {
char r;
GUI_LOCK();
r = _GotoX(x);
GUI_UNLOCK();
return r;
}
char GUI_GotoXY(int x, int y) {
char r;
GUI_LOCK();
r = GUI_GotoX(x);
r |= GUI_GotoY(y);
GUI_UNLOCK();
return r;
}
/*
************************************************************
* *
* GUI_SetLBorder *
* *
* Sets the left border (for carriage return) *
* *
************************************************************
*/
int GUI_SetLBorder(int x) {
int r;
GUI_LOCK();
r = GUI_Context.LBorder;
GUI_Context.LBorder = x;
GUI_UNLOCK();
return r;
}
/*
********************************************************
*
* Display line
*
********************************************************
*/
void GL_DispLine(const char GUI_FAR *s, int Len, const GUI_RECT *pRect) {
/*
Check if we have anything to do at all ...
If the window manager has already set the clipping rect, it does not
make sense to due this. So it makes sense only if
a) The window manager is not used (-> Configuration)
or
b) The window manager is inactive (-> Memory device active)
*/
if (GUI_Context.pClipRect_HL) {
if (GUI_RectsIntersect(GUI_Context.pClipRect_HL, pRect) == 0)
return;
}
if (GUI_Context.pAFont->pafEncode) {
GUI_Context.pAFont->pafEncode->pfDispLine(s, Len);
return;
}
#if (GUI_SUPPORT_UNICODE)
{
U8 c0;
char UCActive=0;
while (--Len >=0) {
c0=*(U8*)s++;
if (UCActive) {
if (c0 == GUI_UC_ENDCHAR)
UCActive = 0;
else {
U8 c1 = *(U8*)s++;
Len--;
GL_DispChar (GUI_DB2UC(c0, c1));
}
} else { /* Unicode not active */
if (c0 == GUI_UC_STARTCHAR)
UCActive = 1;
else
GL_DispChar(c0);
}
}
}
#else
{
while (--Len >=0) {
GL_DispChar(*(U8*)s++);
}
}
#endif
}
void GUI__DispLine(const char GUI_FAR *s, int Len, const GUI_RECT* pr) {
GUI_RECT r;
r = *pr;
#if GUI_WINSUPPORT
WM_ADDORG(r.x0,r.y0);
WM_ADDORG(r.x1,r.y1);
WM_ITERATE_START(&r) {
#endif
GUI_Context.DispPosX = r.x0;
GUI_Context.DispPosY = r.y0;
/* Do the actual drawing via routine call. */
GL_DispLine(s, Len, &r);
#if GUI_WINSUPPORT
} WM_ITERATE_END();
WM_SUBORG(GUI_Context.DispPosX, GUI_Context.DispPosY);
#endif
}
void GUI_DispChars(U16P c, int Cnt) {
while (Cnt-->0)
GUI_DispChar(c);
}
void GUI_DispStringLen(const char GUI_FAR *s, int Len) {
if (s) {
U16 c;
while (Len && ((c=(U16)(*s++))!=0)) {
GUI_DispChar(c);
Len--;
}
}
while (Len--) {
GUI_DispChar(' ');
}
}
void GUI_DispStringAtCEOL(const char GUI_FAR *s, int x, int y) {
GUI_DispStringAt(s,x,y);
GUI_DispCEOL();
}
/*
*********************************
* *
* Disp string *
* horizontally centered *
* *
*********************************
*/
void GUI_DispStringHCenterAt(const char GUI_FAR *s, int x, int y) {
int Align = GUI_SetTextAlign((GUI_Context.TextAlign&~GUI_TA_LEFT)|GUI_TA_CENTER);
GUI_DispStringAt (s,x, y);
GUI_SetTextAlign(Align);
}
void GUI_DispStringHCenter(const char GUI_FAR *s) {
int Align = GUI_SetTextAlign((GUI_Context.TextAlign&~GUI_TA_HORIZONTAL)|GUI_TA_CENTER);
GUI_DispString (s);
GUI_SetTextAlign(Align);
}
/********************************************************************
*
* Display String
*
*********************************************************************
*/
void GUI_DispString(const char GUI_FAR *s) {
int xAdjust, yAdjust, xOrg;
int FontSizeY;
if (!s)
return;
GUI_LOCK();
FontSizeY = GUI_Context.pAFont->YDist;
xOrg = GUI_Context.DispPosX;
/* Adjust vertical position */
yAdjust = GUI_GetYAdjust();
GUI_Context.DispPosY -= yAdjust;
for (; *s; s++) {
GUI_RECT r;
int LineLen= GUI__GetLineLen(s,0x7fff);
int xLineSize = GUI_GetLineDistX(s, LineLen);
/* Check if x-position needs to be changed due to h-alignment */
switch (GUI_Context.TextAlign & GUI_TA_HORIZONTAL) {
case GUI_TA_CENTER: xAdjust= xLineSize/2; break;
case GUI_TA_RIGHT: xAdjust= xLineSize; break;
default: xAdjust= 0;
}
r.x0 = GUI_Context.DispPosX -= xAdjust;
r.x1 = r.x0 + xLineSize-1;
r.y0 = GUI_Context.DispPosY;
r.y1 = r.y0 + FontSizeY-1;
GUI__DispLine(s, LineLen, &r);
GUI_Context.DispPosY = r.y0;
s += LineLen;
if ((*s=='\n') || (*s=='\r')) {
switch (GUI_Context.TextAlign & GUI_TA_HORIZONTAL) {
case GUI_TA_CENTER:
case GUI_TA_RIGHT:
GUI_Context.DispPosX = xOrg;
break;
default:
GUI_Context.DispPosX = GUI_Context.LBorder;
break;
}
if (*s=='\n')
GUI_Context.DispPosY += GUI_GetFontDistY();
} else {
GUI_Context.DispPosX = r.x0+xLineSize;
}
if (*s==0) /* end of string (last line) reached ? */
break;
}
GUI_Context.DispPosY += yAdjust;
GUI_Context.TextAlign &= ~GUI_TA_HORIZONTAL;
GUI_UNLOCK();
}
/********************************************************************
*
* GUI_DispStringAt
*
*********************************************************************
*/
void GUI_DispStringAt(const char GUI_FAR *s, int x, int y) {
GUI_LOCK();
GUI_Context.DispPosX = x;
GUI_Context.DispPosY = y;
GUI_DispString(s);
GUI_UNLOCK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -