📄 guicurs.lst
字号:
C51 COMPILER V8.05a GUICURS 04/11/2008 14:18:55 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE GUICURS
OBJECT MODULE PLACED IN GUICurs.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\GUICurs.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND P
-RINT(.\GUICurs.lst) OBJECT(GUICurs.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 : GUICurs.C
16 Purpose : Cursor routines of the graphics library
17 ---------------------------END-OF-HEADER------------------------------
18 */
19
20 #include <stddef.h> /* needed for definition of NULL */
21 #include "gui\Core\GUI_Private.h"
22
23 #if GUI_SUPPORT_CURSOR
24
25 /*******************************************************************
26 *
27 * static data
28 *
29 ********************************************************************
30 */
31
32 static GUI_HMEM _hBuffer;
33 static GUI_RECT _Rect;
34 static char _CursorIsVis; /* Currently visible ? */
35 static char _CursorOn;
36 static const GUI_CURSOR* _pCursor;
37 static U8 _CursorDeActCnt;
38 static int _AllocSize;
39 static int _x, _y; /* Position of hot spot */
40
41
42
43 /*******************************************************************
44 *
45 * static code
46 *
47 ********************************************************************
48 */
49 static void _Undraw(void) {
50 1 int x, y, xSize, ySize;
51 1 LCD_PIXELINDEX* pData;
52 1 /* Save bitmap data */
53 1 GUI_LOCK();
54 1 if (_hBuffer) {
C51 COMPILER V8.05a GUICURS 04/11/2008 14:18:55 PAGE 2
55 2 pData = GUI_ALLOC_h2p(_hBuffer);
56 2 xSize = _Rect.x1 - _Rect.x0 + 1;
57 2 ySize = _Rect.y1 - _Rect.y0 + 1;
58 2 for (y = 0; y < ySize; y++) {
59 3 for (x = 0; x < xSize; x++) {
60 4 LCD_SetPixelIndex(x + _Rect.x0, y + _Rect.y0, *(pData + x));
61 4 }
62 3 pData += _pCursor->pBitmap->XSize;
63 3 }
64 2 }
65 1 GUI_UNLOCK();
66 1 }
67
68
69 static void _Draw(void) {
70 1 int x, y, xSize, ySize;
71 1 LCD_PIXELINDEX* pData;
72 1 const GUI_BITMAP* pBM;
73 1 GUI_LOCK();
74 1 if (_hBuffer) {
75 2 /* Save bitmap data */
76 2 pBM = _pCursor->pBitmap;
77 2 pData = GUI_ALLOC_h2p(_hBuffer);
78 2 xSize = _Rect.x1 - _Rect.x0 + 1;
79 2 ySize = _Rect.y1 - _Rect.y0 + 1;
80 2 for (y = 0; y < ySize; y++) {
81 3 for (x = 0; x < xSize; x++) {
82 4 *(pData + x) = LCD_GetPixelIndex(_Rect.x0 + x, _Rect.y0 + y);
83 4 }
84 3 pData += pBM->XSize;
85 3 }
86 2 /* Draw bitmap */
87 2 GL_DrawBitmap(pBM, _Rect.x0, _Rect.y0);
88 2 }
89 1 GUI_UNLOCK();
90 1 }
91
92 static void _CalcRect(void) {
93 1 if (_pCursor) {
94 2 _Rect.x0 = _x - _pCursor->xHot;
95 2 _Rect.y0 = _y - _pCursor->yHot;
96 2 _Rect.x1 = _Rect.x0 + _pCursor->pBitmap->XSize - 1;
97 2 _Rect.y1 = _Rect.y0 + _pCursor->pBitmap->YSize - 1;
98 2 }
99 1 }
100
101
102 /*******************************************************************
103 *
104 * static Show / Hide
105
106 Purpose:
107 Show / Hide cursor.
108 */
109 static void _Hide(void) {
110 1 GUI_RECT r;
111 1 if (_CursorIsVis) {
112 2 r = GUI_Context.ClipRect;
113 2 LCD_SetClipRectMax();
114 2 _Undraw();
115 2 GUI_Context.ClipRect = r;
116 2 _CursorIsVis = 0;
C51 COMPILER V8.05a GUICURS 04/11/2008 14:18:55 PAGE 3
117 2 }
118 1 }
119
120 static void _Show(void) {
121 1 GUI_RECT r;
122 1 if (_CursorOn && (_CursorDeActCnt==0)) {
123 2 _CursorIsVis = 1;
124 2 r = GUI_Context.ClipRect;
125 2 LCD_SetClipRectMax();
126 2 _Draw();
127 2 GUI_Context.ClipRect = r;
128 2 }
129 1 }
130
131 /*******************************************************************
132 *
133 * _TempHide, _TempUnhide
134
135 Purpose:
136 Hide cursor if a part of the given rectangle is located in the
137 rectangle used for the cursor. This routine is called automatically
138 by the window manager. This way the window manager can
139 automatically make sure that the cursor is always displayed
140 correctly.
141 Params:
142 pRect Rectangle under consideration
143 Return value:
144 0: No action taken
145 Cursor was not visible or not affected because rectangles
146 did not overlap
147 1: Cursor hidden -> WM needs to restore cursor after
148 drawing operation
149 */
150
151
152 static char _TempHide(const GUI_RECT* pRect) {
153 1 if (!_CursorIsVis) {
154 2 return 0; /* Cursor not visible -> nothing to do */
155 2 }
156 1 if ((pRect == NULL) | GUI_RectsIntersect(pRect, &_Rect)) {
157 2 _Hide(); /* Cursor needs to be hidden */
158 2 return 1;
159 2 }
160 1 return 0; /* Cursor not affected -> nothing to do */
161 1 }
162
163 static void _TempUnhide(void) {
164 1 _Show();
165 1 }
166
167 /*******************************************************************
168 *
169 * Public code
170 *
171 ********************************************************************
172 */
173
174 /*******************************************************************
175 *
176 * GUI_CURSOR_Activate
177 * GUI_CURSOR_Deactivate
178
C51 COMPILER V8.05a GUICURS 04/11/2008 14:18:55 PAGE 4
179 Purpose:
180 Allows activation or deactivation of cursor. Can be used to make
181 cursor flash.
182 */
183 void GUI_CURSOR_Activate(void) {
184 1 GUI_LOCK();
185 1 if ((--_CursorDeActCnt) ==0) {
186 2 _Show();
187 2 }
188 1 GUI_UNLOCK();
189 1 }
190
191 void GUI_CURSOR_Deactivate(void) {
192 1 GUI_LOCK();
193 1 if (_CursorDeActCnt++ ==0)
194 1 _Hide();
195 1 GUI_UNLOCK();
196 1 }
197
198
199 /*******************************************************************
200 *
201 * GUI_CURSOR_Select
202 */
203
204 void GUI_CURSOR_Select(const GUI_CURSOR* pCursor) {
205 1 int AllocSize;
206 1 const GUI_BITMAP* pBM;
207 1 GUI_LOCK();
208 1 if (pCursor != _pCursor) {
209 2 pBM = pCursor->pBitmap;
210 2 _Hide();
211 2 AllocSize = pBM->XSize * pBM->YSize * sizeof(LCD_PIXELINDEX);
212 2 if (AllocSize != _AllocSize) {
213 3 GUI_ALLOC_FreePtr(&_hBuffer);
214 3 }
215 2 _hBuffer = GUI_ALLOC_Alloc(AllocSize);
216 2 _CursorOn = 1;
217 2 _pCursor = pCursor;
218 2 _CalcRect();
219 2 _Show();
220 2 }
221 1 GUI_UNLOCK();
222 1 }
223
224
225
226
227 /*******************************************************************
228 *
229 * GUI_CURSOR_Clear
230 *
231 ********************************************************************
232
233 Purpose:
234 Clears cursor.
235 */
236
237 void GUI_CURSOR_Hide(void) {
238 1 GUI_LOCK();
239 1 _Hide();
240 1 _CursorOn = 0;
C51 COMPILER V8.05a GUICURS 04/11/2008 14:18:55 PAGE 5
241 1 /* Set function pointer which window manager can use */
242 1 GUI_CURSOR_pfTempHide = NULL;
243 1 GUI_CURSOR_pfTempUnhide = NULL;
244 1 GUI_UNLOCK();
245 1 }
246
247 /*******************************************************************
248 *
249 * GUI_CURSOR_Show
250 *
251 ********************************************************************
252
253 Purpose:
254 Shows cursor.
255 */
256
257 void GUI_CURSOR_Show(void) {
258 1 GUI_LOCK();
259 1 _Hide();
260 1 _CursorOn = 1;
261 1 /* Set function pointer which window manager can use */
262 1 GUI_CURSOR_pfTempHide = _TempHide;
263 1 GUI_CURSOR_pfTempUnhide = _TempUnhide;
264 1 if (!_pCursor) {
265 2 GUI_CURSOR_Select(GUI_DEFAULT_CURSOR);
266 2 } else {
267 2 _Show();
268 2 }
269 1 GUI_UNLOCK();
270 1 }
271
272 /*******************************************************************
273 *
274 * GUI_CURSOR_SetPosition
275
276 Purpose:
277 Sets position of cursor.
278 */
279
280 void GUI_CURSOR_SetPosition(int x, int y) {
281 1 GUI_LOCK();
282 1 if ((_x != x) | (_y != y)) {
283 2 _Hide();
284 2 _x = x;
285 2 _y = y;
286 2 _CalcRect();
287 2 _Show();
288 2 }
289 1 GUI_UNLOCK();
290 1 }
291
292 #else
void GUICurs_C(void) {} /* avoid empty object files */
#endif /* GUI_SUPPORT_CURSOR */
297
298
299
300
301
302
C51 COMPILER V8.05a GUICURS 04/11/2008 14:18:55 PAGE 6
303
304
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1387 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 22 56
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -