📄 guichar.lst
字号:
C51 COMPILER V8.05a GUICHAR 04/11/2008 14:18:54 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE GUICHAR
OBJECT MODULE PLACED IN GUIChar.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\GUIChar.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND P
-RINT(.\GUIChar.lst) OBJECT(GUIChar.obj)
line level source
1 /*
2 *********************************************************************************************************
3 * uC/GUI
4 * Universal graphic software for embedded applications
5 *
6 * (c) Copyright 2002, Micrium Inc., Weston, FL
7 * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
8 *
9 * 礐/GUI is protected by international copyright laws. Knowledge of the
10 * source code may not be used to write a similar product. This file may
11 * only be used in accordance with a license and should not be redistributed
12 * in any way. We appreciate your understanding and fairness.
13 *
14 ----------------------------------------------------------------------
15 File : GUIChar.C
16 Purpose : Implementation of character and string services
17 ---------------------------END-OF-HEADER------------------------------
18 */
19
20
21 #include <stddef.h> /* needed for definition of NULL */
22 #include <stdio.h>
23 #include <string.h>
24 #include "gui\Core\GUI_Private.h"
25
26
27 /**********************************************************
28 *
29 * Public code
30 *
31 ***********************************************************
32 */
33
34
35 /***********************************************************
36 *
37 * GUI_DispChar
38 */
39
40 void GL_DispChar(U16 c) {
41 1 /* check for control characters */
42 1 if (c == '\n') {
43 2 GUI_DispNextLine();
44 2 } else {
45 2 if (c != '\r') {
46 3 GUI_Context.pAFont->pfDispChar(c);
47 3 }
48 2 }
49 1 }
50
51
52 /*************** GUI_GetStringDistX ****************************
53 This routine is used to calculate the length of a string in pixels.
54 */
C51 COMPILER V8.05a GUICHAR 04/11/2008 14:18:54 PAGE 2
55
56 int GUI_GetLineDistX(const char GUI_FAR *s, int Len) {
57 1 int Dist =0;
58 1 if (s) {
59 2 if (GUI_Context.pAFont->pafEncode) {
60 3 return GUI_Context.pAFont->pafEncode->pfGetLineDistX(s, Len);
61 3 }
62 2 #if (GUI_SUPPORT_UNICODE)
63 2 {
64 3 U8 c0;
65 3 char UCActive=0;
66 3 while (((c0=*(U8*)s) !=0) && Len >0) {
67 4 s++; Len--;
68 4 if (UCActive) {
69 5 if (c0 == GUI_UC_ENDCHAR)
70 5 UCActive = 0;
71 5 else {
72 6 U8 c1 = *(U8*)s++;
73 6 Len--;
74 6 Dist += GUI_GetCharDistX(GUI_DB2UC(c0, c1));
75 6 }
76 5 } else { /* Unicode not active */
77 5 if (c0 == GUI_UC_STARTCHAR)
78 5 UCActive = 1;
79 5 else
80 5 Dist += GUI_GetCharDistX(c0);
81 5 }
82 4 }
83 3 }
84 2 #else
while (--Len>=0) {
Dist += GUI_GetCharDistX(*(U8*)s++);
}
#endif
89 2 }
90 1 return Dist;
91 1 }
92
93 /*************** GUI_GetLineLen ****************************
94 Returns the number of characters in a string
95 Note: The return value can be used as offset into the
96 string, which means that double characters count double
97 */
98
99 int GUI__GetLineLen(const char GUI_FAR *s, int MaxLen) {
100 1 int Len =0;
101 1 if (!s)
102 1 return 0;
103 1 if (GUI_Context.pAFont->pafEncode) {
104 2 return GUI_Context.pAFont->pafEncode->pfGetLineLen(s, MaxLen);
105 2 }
106 1 #if (GUI_SUPPORT_UNICODE)
107 1 {
108 2 U8 c0;
109 2 char UCActive=0;
110 2 while (((c0=*(U8*)s) !=0) && Len < MaxLen) {
111 3 s++;
112 3 if (UCActive) {
113 4 switch (c0) {
114 5 case GUI_UC_ENDCHAR: UCActive = 0; break;
115 5 default: Len++; s++;
116 5 }
C51 COMPILER V8.05a GUICHAR 04/11/2008 14:18:54 PAGE 3
117 4 } else { /* Unicode not active */
118 4 switch (c0) {
119 5 case GUI_UC_STARTCHAR: UCActive = 1; break;
120 5 case '\n': return Len;
121 5 case '\r': return Len;
122 5 }
123 4 }
124 3 Len++;
125 3 }
126 2 }
127 1 #else
for (;Len<MaxLen; Len++) {
U8 Data = *(U8*)s++;
if ((Data == 0) || (Data == '\n'))
break;
}
#endif
134 1 return Len;
135 1 }
136
137
138 /**********************************************************************
139 *
140 * "GET" routines (information retrieval)
141 *
142 ***********************************************************************
143
144 These routines all return a value like selected font, current display
145 position in x/y direction, window size in x/y direction,
146 font size and matrix in x/y.
147 The routines prefixed with GUI_ can be called from the application
148 program or emWin internally, while the routines without that prefix
149 are not supposed to be called from outside emWin.
150 The main reason is that GUI_LOCK has to be called before these
151 values can be reliably retrieved in a multitasking environment.
152
153 */
154
155 /*------------------------------------------------------------------
156 GUI_GetYAdjust --- returns adjustment in vertical (Y) direction
157 The return value needs to be subtracted from
158 the y-position of the character
159 */
160
161 int GUI_GetYAdjust(void) {
162 1 switch (GUI_Context.TextAlign&GUI_TA_VERTICAL) {
163 2 case GUI_TA_BOTTOM:
164 2 return GUI_Context.pAFont->YSize-1;
165 2 case GUI_TA_VCENTER:
166 2 return GUI_Context.pAFont->YSize/2;
167 2 case GUI_TA_BASELINE:
168 2 return GUI_Context.pAFont->YSize/2;
169 2 }
170 1 return 0;
171 1 }
172
173
174
175 /*
176 *******************************************
177 * *
178 * Get Font Spacing routines *
C51 COMPILER V8.05a GUICHAR 04/11/2008 14:18:54 PAGE 4
179 * *
180 *******************************************
181 */
182
183 int GUI_GetFontDistY(void) {
184 1 int r;
185 1 GUI_LOCK();
186 1 r = GUI_Context.pAFont->YDist * GUI_Context.pAFont->YMag;
187 1 GUI_UNLOCK();
188 1 return r;
189 1 }
190
191
192 /*
193 *******************************************
194 * *
195 * Get Char spacing routines *
196 * *
197 *******************************************
198 */
199
200 int GUI_GetCharDistX(U16 c) {
201 1 int r;
202 1 GUI_LOCK();
203 1 r = GUI_Context.pAFont->pfGetCharDistX(c);
204 1 GUI_UNLOCK();
205 1 return r;
206 1 }
207
208
209
210
211
212
213
214
215 /*
216 *********************************
217 * *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -