Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /***************************************************************************** |
2 | * Module for Microchip Graphics Library |
||
3 | * Graphic Primitives Layer |
||
4 | ***************************************************************************** |
||
5 | * FileName: Primitive.h |
||
6 | * Dependencies: |
||
7 | * Processor: PIC24F, PIC24H, dsPIC, PIC32 |
||
8 | * Compiler: MPLAB C30, MPLAB C32 |
||
9 | * Linker: MPLAB LINK30, MPLAB LINK32 |
||
10 | * Company: Microchip Technology Incorporated |
||
11 | * |
||
12 | * Software License Agreement |
||
13 | * |
||
14 | * Copyright © 2008 Microchip Technology Inc. All rights reserved. |
||
15 | * Microchip licenses to you the right to use, modify, copy and distribute |
||
16 | * Software only when embedded on a Microchip microcontroller or digital |
||
17 | * signal controller, which is integrated into your product or third party |
||
18 | * product (pursuant to the sublicense terms in the accompanying license |
||
19 | * agreement). |
||
20 | * |
||
21 | * You should refer to the license agreement accompanying this Software |
||
22 | * for additional information regarding your rights and obligations. |
||
23 | * |
||
24 | * SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY |
||
25 | * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
26 | * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR |
||
27 | * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR |
||
28 | * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, |
||
29 | * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT |
||
30 | * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, |
||
31 | * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, |
||
32 | * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY |
||
33 | * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), |
||
34 | * OR OTHER SIMILAR COSTS. |
||
35 | * |
||
36 | * Author Date Comment |
||
37 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
38 | * Anton Alkhimenok and |
||
39 | * Paolo A. Tamayo 11/12/07 Version 1.0 release |
||
40 | * Pradeep Budagutta 18/05/2009 Version 1.1 - All Primitive functions have |
||
41 | * return value(To support 2d-Acceleration) |
||
42 | *****************************************************************************/ |
||
43 | #ifndef _PRIMITIVE_H |
||
44 | #define _PRIMITIVE_H |
||
45 | |||
46 | /********************************************************************* |
||
47 | * Overview: Primitive lines are drawn using line type and line thickness. |
||
48 | * There are 3 line styles and 2 types of line thickness. |
||
49 | * |
||
50 | *********************************************************************/ |
||
51 | |||
52 | // Solid Line Style |
||
53 | #define SOLID_LINE 0 |
||
54 | |||
55 | // Dotted Line Style |
||
56 | #define DOTTED_LINE 1 |
||
57 | |||
58 | // Dashed Line Style |
||
59 | #define DASHED_LINE 4 |
||
60 | |||
61 | // Normal Line (thickness is 1 pixel) |
||
62 | #define NORMAL_LINE 0 |
||
63 | |||
64 | // Thick Line (thickness is 3 pixels) |
||
65 | #define THICK_LINE 1 |
||
66 | |||
67 | /********************************************************************* |
||
68 | * Overview: Drawing bitmaps will have two modes, normal rendering |
||
69 | * and stretched rendering. Stretched rendering effectively |
||
70 | * doubles the image size in the horizontal and vertical |
||
71 | * direction. |
||
72 | * |
||
73 | *********************************************************************/ |
||
74 | |||
75 | // Normal image stretch code |
||
76 | #define IMAGE_NORMAL 1 |
||
77 | |||
78 | // Stretched image stretch code |
||
79 | #define IMAGE_X2 2 |
||
80 | |||
81 | // Current line style |
||
82 | extern SHORT _lineType; |
||
83 | |||
84 | // Current line thickness |
||
85 | extern BYTE _lineThickness; |
||
86 | |||
87 | // constants used for circle/arc computation |
||
88 | #define SIN45 46341 // sin(45) * 2^16) |
||
89 | #define ONEP25 81920 // 1.25 * 2^16 |
||
90 | |||
91 | // Current cursor coordinates |
||
92 | extern SHORT _cursorX; |
||
93 | extern SHORT _cursorY; |
||
94 | |||
95 | // Font orientation |
||
96 | extern BYTE _fontOrientation; |
||
97 | |||
98 | #define ORIENT_HOR 0 |
||
99 | #define ORIENT_VER 1 |
||
100 | |||
101 | // Character type used |
||
102 | #ifdef USE_MULTIBYTECHAR |
||
103 | #define XCHAR unsigned short |
||
104 | #else |
||
105 | #define XCHAR char |
||
106 | #endif |
||
107 | |||
108 | // bevel drawing type (0 = full bevel, 0xF0 - top bevel only, 0x0F - bottom bevel only |
||
109 | extern BYTE _bevelDrawType; |
||
110 | |||
111 | #define DRAWFULLBEVEL 0xFF |
||
112 | #define DRAWTOPBEVEL 0xF0 |
||
113 | #define DRAWBOTTOMBEVEL 0x0F |
||
114 | |||
115 | // Memory type enumeration to determine the source of data. |
||
116 | // Used in interpreting bitmap and font from different memory sources. |
||
117 | typedef enum |
||
118 | { |
||
119 | FLASH = 0, // internal flash |
||
120 | EXTERNAL= 1, // external memory |
||
121 | RAM = 2, // RAM |
||
122 | VIDEOBUF= 3, // video buffer |
||
123 | EDS = 4 // EDS memory (RAM, internal PSV Flash, or external EPMP). |
||
124 | } TYPE_MEMORY; |
||
125 | |||
126 | /********************************************************************* |
||
127 | * Overview: This structure is used to describe external memory. |
||
128 | * |
||
129 | *********************************************************************/ |
||
130 | typedef struct |
||
131 | { |
||
132 | TYPE_MEMORY type; // must be EXTERNAL |
||
133 | WORD ID; // memory ID |
||
134 | DWORD address; // bitmap or font image address |
||
135 | } EXTDATA; |
||
136 | |||
137 | #ifdef __PIC32MX__ |
||
138 | #define FLASH_BYTE const BYTE |
||
139 | #define FLASH_WORD const WORD |
||
140 | #else |
||
141 | |||
142 | // Flash data with 24bit pointers |
||
143 | #define FLASH_BYTE char __prog__ |
||
144 | #define FLASH_WORD short int __prog__ |
||
145 | #endif |
||
146 | |||
147 | /********************************************************************* |
||
148 | * Overview: Structure describing the bitmap header. |
||
149 | * |
||
150 | *********************************************************************/ |
||
151 | typedef struct |
||
152 | { |
||
153 | BYTE compression; // Compression setting |
||
154 | BYTE colorDepth; // Color depth used |
||
155 | SHORT height; // Image height |
||
156 | SHORT width; // Image width |
||
157 | } BITMAP_HEADER; |
||
158 | |||
159 | /********************************************************************* |
||
160 | * Overview: Structure for bitmap stored in FLASH memory. |
||
161 | * |
||
162 | *********************************************************************/ |
||
163 | typedef struct |
||
164 | { |
||
165 | TYPE_MEMORY type; // must be FLASH |
||
166 | FLASH_BYTE *address; // bitmap image address |
||
167 | } BITMAP_FLASH; |
||
168 | |||
169 | /********************************************************************* |
||
170 | * Overview: Structure for bitmap stored in RAM memory. |
||
171 | * |
||
172 | *********************************************************************/ |
||
173 | typedef struct |
||
174 | { |
||
175 | TYPE_MEMORY type; // must be RAM |
||
176 | char *address; // bitmap image address in RAM |
||
177 | } BITMAP_RAM; |
||
178 | |||
179 | /********************************************************************* |
||
180 | * Overview: Structure for bitmap stored in EDS memory (RAM, internal PSV Flash, or external EPMP). |
||
181 | * |
||
182 | *********************************************************************/ |
||
183 | typedef struct |
||
184 | { |
||
185 | TYPE_MEMORY type; // Must be EDS |
||
186 | unsigned long address; // Bitmap image address in EDS |
||
187 | unsigned long fileLength; // Number of bytes in the image |
||
188 | } BITMAP_EDS; |
||
189 | |||
190 | |||
191 | // Structure for bitmap stored in EXTERNAL memory |
||
192 | #define BITMAP_EXTERNAL EXTDATA |
||
193 | |||
194 | /********************************************************************* |
||
195 | * Overview: Structure describing the font header. |
||
196 | * |
||
197 | *********************************************************************/ |
||
198 | typedef struct |
||
199 | { |
||
200 | BYTE fontID; // User assigned value |
||
201 | BYTE res1 : 4; // Reserved for future use (must be set to 0). |
||
202 | BYTE orient : 2; // Orientation |
||
203 | BYTE res2 : 2; // Reserved for future use (must be set to 0). |
||
204 | WORD firstChar; // Character code of first character (e.g. 32). |
||
205 | WORD lastChar; // Character code of last character in font (e.g. 3006). |
||
206 | BYTE height; // Font characters height in pixels. |
||
207 | BYTE reserved; // Reserved for future use (must be set to 0). |
||
208 | } FONT_HEADER; |
||
209 | |||
210 | // Structure describing font glyph entry |
||
211 | typedef struct |
||
212 | { |
||
213 | BYTE width; |
||
214 | BYTE offsetLSB; |
||
215 | WORD offsetMSB; |
||
216 | } GLYPH_ENTRY; |
||
217 | |||
218 | /********************************************************************* |
||
219 | * Overview: Structure for font stored in FLASH memory. |
||
220 | * |
||
221 | *********************************************************************/ |
||
222 | typedef struct |
||
223 | { |
||
224 | TYPE_MEMORY type; // must be FLASH |
||
225 | const char *address; // font image address |
||
226 | } FONT_FLASH; |
||
227 | |||
228 | /********************************************************************* |
||
229 | * Overview: Structure for font stored in RAM memory. |
||
230 | * |
||
231 | *********************************************************************/ |
||
232 | typedef struct |
||
233 | { |
||
234 | TYPE_MEMORY type; // must be RAM |
||
235 | const char *address; // bitmap image address in RAM |
||
236 | } FONT_RAM; |
||
237 | |||
238 | // Structure for font stored in EXTERNAL memory |
||
239 | #define FONT_EXTERNAL EXTDATA |
||
240 | |||
241 | /********************************************************************* |
||
242 | * Overview: This defines the size of the buffer used by font functions |
||
243 | * to retrieve font data from the external memory. The buffer |
||
244 | * size can be increased to accommodate large font sizes. |
||
245 | * The user must be aware of the expected glyph sizes of the |
||
246 | * characters stored in the font table. |
||
247 | * |
||
248 | ********************************************************************/ |
||
249 | #define EXTERNAL_FONT_BUFFER_SIZE 600 |
||
250 | |||
251 | // Pointer to the current font image |
||
252 | extern void *_font; |
||
253 | |||
254 | // First and last characters in the font |
||
255 | extern WORD _fontFirstChar; |
||
256 | extern WORD _fontLastChar; |
||
257 | |||
258 | // Installed font height |
||
259 | extern SHORT _fontHeight; |
||
260 | |||
261 | /********************************************************************* |
||
262 | * Function: WORD Arc(SHORT xL, SHORT yT, SHORT xR, SHORT yB, |
||
263 | * SHORT r1, SHORT r2, BYTE octant) |
||
264 | * |
||
265 | * Overview: Draws the octant arc of a beveled figure with given centers, radii |
||
266 | * and octant mask. When r1 is zero and r2 has some value, a filled |
||
267 | * circle is drawn; when the radii have values, an arc of |
||
268 | * thickness (r2-r1) is drawn; when octant = 0xFF, a full ring |
||
269 | * is drawn. When r1 and r2 are zero, a rectangular object is drawn, where |
||
270 | * xL, yT specifies the left top corner; xR, yB specifies the right bottom |
||
271 | * corner. |
||
272 | * |
||
273 | * PreCondition: none |
||
274 | * |
||
275 | * Input: xL - x location of the upper left center in the x,y coordinate. |
||
276 | * yT - y location of the upper left center in the x,y coordinate. |
||
277 | * xR - x location of the lower right center in the x,y coordinate. |
||
278 | * yB - y location of the lower right center in the x,y coordinate. |
||
279 | * r1 - The smaller radius of the two concentric cicles that defines the thickness |
||
280 | * of the object. |
||
281 | * r2 - The larger of radius the two concentric circles that defines the thickness |
||
282 | * of the object. |
||
283 | * octant - Bitmask of the octant that will be drawn. |
||
284 | * Moving in a clockwise direction from x = 0, y = +radius |
||
285 | * - bit0 : first octant |
||
286 | * - bit1 : second octant |
||
287 | * - bit2 : third octant |
||
288 | * - bit3 : fourth octant |
||
289 | * - bit4 : fifth octant |
||
290 | * - bit5 : sixth octant |
||
291 | * - bit6 : seventh octant |
||
292 | * - bit7 : eight octant |
||
293 | * |
||
294 | * Output: Returns the rendering status. |
||
295 | * 1 - If the rendering was completed and |
||
296 | * 0 - If the rendering is not yet finished. |
||
297 | * |
||
298 | * Side Effects: none |
||
299 | * |
||
300 | ********************************************************************/ |
||
301 | WORD Arc(SHORT xL, SHORT yT, SHORT xR, SHORT yB, SHORT r1, SHORT r2, BYTE octant); |
||
302 | |||
303 | /********************************************************************* |
||
304 | * Function: void InitGraph(void) |
||
305 | * |
||
306 | * Overview: This function initializes the display controller, sets |
||
307 | * the line type to SOLID_LINE, sets the screen to all BLACK, |
||
308 | * sets the current drawing color to WHITE, sets the graphic |
||
309 | * cursor position to upper left corner of the screen, sets |
||
310 | * active and visual pages to page #0, clears the active page |
||
311 | * and disables clipping. This function should be called before |
||
312 | * using the Graphics Primitive Layer. |
||
313 | * |
||
314 | * PreCondition: none |
||
315 | * |
||
316 | * Input: none |
||
317 | * |
||
318 | * Output: none |
||
319 | * |
||
320 | * Side Effects: none |
||
321 | * |
||
322 | ********************************************************************/ |
||
323 | void InitGraph(void); |
||
324 | |||
325 | /********************************************************************* |
||
326 | * Macros: GetX() |
||
327 | * |
||
328 | * Overview: This macro returns the current graphic cursor x-coordinate. |
||
329 | * |
||
330 | * PreCondition: none |
||
331 | * |
||
332 | * Input: none |
||
333 | * |
||
334 | * Output: none |
||
335 | * |
||
336 | * Side Effects: none |
||
337 | * |
||
338 | ********************************************************************/ |
||
339 | #define GetX() _cursorX |
||
340 | |||
341 | /********************************************************************* |
||
342 | * Macros: GetX() |
||
343 | * |
||
344 | * Overview: This macro returns the current graphic cursor y-coordinate. |
||
345 | * |
||
346 | * PreCondition: none |
||
347 | * |
||
348 | * Input: none |
||
349 | * |
||
350 | * Output: none |
||
351 | * |
||
352 | * Side Effects: none |
||
353 | * |
||
354 | ********************************************************************/ |
||
355 | #define GetY() _cursorY |
||
356 | |||
357 | /********************************************************************* |
||
358 | * Macros: MoveTo(x,y) |
||
359 | * |
||
360 | * Overview: This macro moves the graphic cursor to new x,y position. |
||
361 | * |
||
362 | * PreCondition: none |
||
363 | * |
||
364 | * Input: x - Specifies the new x position of the graphic cursor. |
||
365 | * y - Specifies the new y position of the graphic cursor. |
||
366 | * |
||
367 | * Output: none |
||
368 | * |
||
369 | * Side Effects: none |
||
370 | * |
||
371 | ********************************************************************/ |
||
372 | #define MoveTo(x, y) \ |
||
373 | _cursorX = x; \ |
||
374 | _cursorY = y; |
||
375 | |||
376 | /********************************************************************* |
||
377 | * Macros: MoveRel(dX,dY) |
||
378 | * |
||
379 | * Overview: This macro moves the graphic cursor relative to the |
||
380 | * current location. The given dX and dY displacement can |
||
381 | * be positive or negative numbers. |
||
382 | * |
||
383 | * PreCondition: none |
||
384 | * |
||
385 | * Input: dX - Specifies the displacement of the graphic cursor for |
||
386 | * the horizontal direction. |
||
387 | * dY - Specifies the displacement of the graphic cursor for |
||
388 | * the vertical direction. |
||
389 | * |
||
390 | * Output: none |
||
391 | * |
||
392 | * Side Effects: none |
||
393 | * |
||
394 | ********************************************************************/ |
||
395 | #define MoveRel(dX, dY) \ |
||
396 | _cursorX += dX; \ |
||
397 | _cursorY += dY; |
||
398 | |||
399 | /********************************************************************* |
||
400 | * Macro: SetFontOrientation(orient) |
||
401 | * |
||
402 | * Overview: This macro sets font orientation vertical or horizontal. |
||
403 | * |
||
404 | * PreCondition: none |
||
405 | * |
||
406 | * Input: orient - should be non-zero if the font orientation is vertical |
||
407 | * |
||
408 | * Output: none |
||
409 | * |
||
410 | ********************************************************************/ |
||
411 | #define SetFontOrientation(orient) _fontOrientation = orient; |
||
412 | |||
413 | /********************************************************************* |
||
414 | * Macro: GetFontOrientation() |
||
415 | * |
||
416 | * Overview: This macro returns font orientation (0 == horizontal, 1 == vertical). |
||
417 | * |
||
418 | * PreCondition: none |
||
419 | * |
||
420 | * Input: none |
||
421 | * |
||
422 | * Output: font orientation (0 == horizontal, 1 == vertical) |
||
423 | * |
||
424 | ********************************************************************/ |
||
425 | #define GetFontOrientation() _fontOrientation |
||
426 | |||
427 | /********************************************************************* |
||
428 | * Function: WORD OutChar(XCHAR ch) |
||
429 | * |
||
430 | * Overview: This function outputs a character from the current graphic |
||
431 | * cursor position. OutChar() uses the current active font |
||
432 | * set with SetFont(). |
||
433 | * |
||
434 | * PreCondition: none |
||
435 | * |
||
436 | * Input: ch - The character code to be displayed. |
||
437 | * |
||
438 | * Output: For NON-Blocking configuration: |
||
439 | * - Returns 0 when device is busy and the character is not yet completely drawn. |
||
440 | * - Returns 1 when the character is completely drawn. |
||
441 | * For Blocking configuration: |
||
442 | * - Always return 1. |
||
443 | * |
||
444 | * |
||
445 | * Side Effects: After the function is completed, the graphic cursor |
||
446 | * position is moved in the horizontal direction by the |
||
447 | * character width. Vertical position of the graphic cursor |
||
448 | * is not changed. |
||
449 | * |
||
450 | ********************************************************************/ |
||
451 | WORD OutChar(XCHAR ch); |
||
452 | |||
453 | /********************************************************************* |
||
454 | * Function: WORD OutText(XCHAR* textString) |
||
455 | * |
||
456 | * Overview: This function outputs a string of characters starting |
||
457 | * at the current graphic cursor position. The string must |
||
458 | * be terminated by a line feed or zero. For Non-Blocking |
||
459 | * configuration, OutText() may return control to the program |
||
460 | * due to display device busy status. When this happens zero |
||
461 | * is returned and OutText() must be called again to continue |
||
462 | * the outputting of the string. For Blocking configuration, |
||
463 | * this function always returns a 1. OutText() uses the current |
||
464 | * active font set with SetFont(). |
||
465 | * |
||
466 | * |
||
467 | * Input: textString - Pointer to the string to be displayed. |
||
468 | * |
||
469 | * Output: For NON-Blocking configuration: |
||
470 | * - Returns 0 when string is not yet outputted completely. |
||
471 | * - Returns 1 when string is outputted completely. |
||
472 | * For Blocking configuration: |
||
473 | * - Always return 1. |
||
474 | * |
||
475 | * Side Effects: Current horizontal graphic cursor position will be moved |
||
476 | * to the end of the text. The vertical graphic cursor |
||
477 | * position will not be changed. |
||
478 | * |
||
479 | ********************************************************************/ |
||
480 | WORD OutText(XCHAR *textString); |
||
481 | |||
482 | /********************************************************************* |
||
483 | * Function: WORD OutTextXY(SHORT x, SHORT y, XCHAR* textString) |
||
484 | * |
||
485 | * Overview: This function outputs a string of characters starting |
||
486 | * at the given x, y position. The string must be terminated |
||
487 | * by a line feed or zero. For Non-Blocking configuration, |
||
488 | * OutTextXY() may return control to the program due to |
||
489 | * display device busy status. When this happens zero is |
||
490 | * returned and OutTextXY() must be called again to continue |
||
491 | * the outputting of the string. For Blocking configuration, |
||
492 | * this function always returns a 1. OutTextXY() uses the |
||
493 | * current active font set with SetFont(). |
||
494 | * |
||
495 | * Input: x - Defines the x starting position of the string. |
||
496 | * y - Defines the y starting position of the string. |
||
497 | * textString - Pointer to the string to be displayed. |
||
498 | * |
||
499 | * Output: For NON-Blocking configuration: |
||
500 | * - Returns 0 when string is not yet outputted completely. |
||
501 | * - Returns 1 when string is outputted completely. |
||
502 | * For Blocking configuration: |
||
503 | * - Always return 1. |
||
504 | * |
||
505 | * Example: |
||
506 | * <CODE> |
||
507 | * void PlaceText(void) |
||
508 | * { |
||
509 | * SHORT width, height; |
||
510 | * static const XCHAR text[] = "Touch screen to continue"; |
||
511 | * |
||
512 | * SetColor(BRIGHTRED); // set color |
||
513 | * SetFont(pMyFont); // set font to my font |
||
514 | * |
||
515 | * // get string width & height |
||
516 | * width = GetTextWidth(text, pMyFont); |
||
517 | * height = GetTextHeight(pMyFont); |
||
518 | * |
||
519 | * // place string in the middle of the screen |
||
520 | * OutTextXY( (GetMaxX() - width) >> 1, \ |
||
521 | * (GetMaxY() height) >> 1, \ |
||
522 | * (char*)text); |
||
523 | * } |
||
524 | * </CODE> |
||
525 | * |
||
526 | * Side Effects: Current horizontal graphic cursor position will be |
||
527 | * moved to the end of the text. The vertical graphic |
||
528 | * cursor position will not be changed. |
||
529 | * |
||
530 | ********************************************************************/ |
||
531 | WORD OutTextXY(SHORT x, SHORT y, XCHAR *textString); |
||
532 | |||
533 | /********************************************************************* |
||
534 | * Function: SHORT GetTextHeight(void* font) |
||
535 | * |
||
536 | * Overview: This macro returns the height of the specified font. |
||
537 | * All characters in a given font table have a constant |
||
538 | * height. |
||
539 | * |
||
540 | * Input: font - Pointer to the font image. |
||
541 | * |
||
542 | * Output: Returns the font height. |
||
543 | * |
||
544 | * Example: |
||
545 | * See OutTextXY() example. |
||
546 | * |
||
547 | * Side Effects: none |
||
548 | * |
||
549 | ********************************************************************/ |
||
550 | SHORT GetTextHeight(void *font); |
||
551 | |||
552 | /********************************************************************* |
||
553 | * Function: SHORT GetTextWidth(XCHAR* textString, void* font) |
||
554 | * |
||
555 | * Overview: This function returns the width of the specified string |
||
556 | * for the specified font. The string must be terminated |
||
557 | * by a line feed or zero. |
||
558 | * |
||
559 | * Input: textString - Pointer to the string. |
||
560 | * font - Pointer to the font image. |
||
561 | * |
||
562 | * Output: Returns the string width in the specified font. |
||
563 | * |
||
564 | * Example: |
||
565 | * See OutTextXY() example. |
||
566 | * |
||
567 | * Side Effects: none |
||
568 | * |
||
569 | ********************************************************************/ |
||
570 | SHORT GetTextWidth(XCHAR *textString, void *font); |
||
571 | |||
572 | /********************************************************************* |
||
573 | * Function: void SetFont(void* font) |
||
574 | * |
||
575 | * Overview: This function sets the current font used in OutTextXY(), |
||
576 | * OutText() and OutChar() functions. |
||
577 | * |
||
578 | * Input: font - Pointer to the new font image to be used. |
||
579 | * |
||
580 | * Output: none |
||
581 | * |
||
582 | * Example: |
||
583 | * See OutTextXY() example. |
||
584 | * |
||
585 | * Side Effects: none |
||
586 | * |
||
587 | ********************************************************************/ |
||
588 | void SetFont(void *font); |
||
589 | |||
590 | /********************************************************************* |
||
591 | * Macros: SetLineType(lnType) |
||
592 | * |
||
593 | * Overview: This macro sets the line type to draw. |
||
594 | * |
||
595 | * Input: lnType - The type of line to be used. |
||
596 | * Supported line types: |
||
597 | * - SOLID_LINE |
||
598 | * - DOTTED_LINE |
||
599 | * - DASHED_LINE |
||
600 | * |
||
601 | * Output: none |
||
602 | * |
||
603 | * Side Effects: none |
||
604 | * |
||
605 | ********************************************************************/ |
||
606 | #define SetLineType(lnType) _lineType = lnType; |
||
607 | |||
608 | /********************************************************************* |
||
609 | * Macros: SetLineThickness(lnThickness) |
||
610 | * |
||
611 | * Overview: This macro sets sets line thickness to 1 pixel or 3 pixels. |
||
612 | * |
||
613 | * Input: lnThickness - Line thickness code (0 - 1 pixel; 1 - 3 pixels) |
||
614 | * |
||
615 | * Output: none |
||
616 | * |
||
617 | * Side Effects: none |
||
618 | * |
||
619 | ********************************************************************/ |
||
620 | #define SetLineThickness(lnThickness) _lineThickness = lnThickness; |
||
621 | |||
622 | /********************************************************************* |
||
623 | * Function: WORD Line(SHORT x1, SHORT y1, SHORT x2, SHORT y2) |
||
624 | * |
||
625 | * Overview: This function draws a line with the current line type |
||
626 | * from the start point to the end point. |
||
627 | * |
||
628 | * Input: x1 - x coordinate of the start point. |
||
629 | * y1 - y coordinate of the start point. |
||
630 | * x2 - x coordinate of the end point. |
||
631 | * y2 - y coordinate of the end point. |
||
632 | * |
||
633 | * Output: For NON-Blocking configuration: |
||
634 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
635 | * - Returns 1 when the shape is completely drawn. |
||
636 | * For Blocking configuration: |
||
637 | * - Always return 1. |
||
638 | * |
||
639 | * |
||
640 | * Side Effects: The graphic cursor position is moved to the end |
||
641 | * point of the line. |
||
642 | * |
||
643 | ********************************************************************/ |
||
644 | WORD Line(SHORT x1, SHORT y1, SHORT x2, SHORT y2); |
||
645 | |||
646 | /********************************************************************* |
||
647 | * Macros: LineRel(dX, dY) |
||
648 | * |
||
649 | * Overview: This macro draws a line with the current line type from |
||
650 | * the current graphic cursor position to the position defined |
||
651 | * by displacement. |
||
652 | * |
||
653 | * Input: dX - Displacement from the current x position. |
||
654 | * dY - Displacement from the current y position. |
||
655 | * |
||
656 | * Output: For NON-Blocking configuration: |
||
657 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
658 | * - Returns 1 when the shape is completely drawn. |
||
659 | * For Blocking configuration: |
||
660 | * - Always return 1. |
||
661 | * |
||
662 | * Side Effects: The graphic cursor position is moved to the end |
||
663 | * point of the line. |
||
664 | * |
||
665 | ********************************************************************/ |
||
666 | #define LineRel(dX, dY) Line(GetX(), GetY(), GetX() + dX, GetY() + dY) |
||
667 | |||
668 | /********************************************************************* |
||
669 | * Macros: LineTo(x,y) |
||
670 | * |
||
671 | * Overview: This macro draws a line with the current line type from |
||
672 | * the current graphic cursor position to the given x, y position. |
||
673 | * |
||
674 | * Input: x - End point x position. |
||
675 | * y - End point y poisiton. |
||
676 | * |
||
677 | * Output: For NON-Blocking configuration: |
||
678 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
679 | * - Returns 1 when the shape is completely drawn. |
||
680 | * For Blocking configuration: |
||
681 | * - Always return 1. |
||
682 | * |
||
683 | * Side Effects: The graphic cursor position is moved to the end |
||
684 | * point of the line. |
||
685 | * |
||
686 | ********************************************************************/ |
||
687 | #define LineTo(x, y) Line(_cursorX, _cursorY, x, y) |
||
688 | |||
689 | /********************************************************************* |
||
690 | * Macro: Circle(x, y, radius) |
||
691 | * |
||
692 | * Overview: This macro draws a circle with the given center and radius. |
||
693 | * |
||
694 | * Input: x - Center x position. |
||
695 | * y - Center y position. |
||
696 | * radius - the radius of the circle. |
||
697 | * |
||
698 | * Output: For NON-Blocking configuration: |
||
699 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
700 | * - Returns 1 when the shape is completely drawn. |
||
701 | * For Blocking configuration: |
||
702 | * - Always return 1. |
||
703 | * |
||
704 | * Side Effects: none |
||
705 | * |
||
706 | ********************************************************************/ |
||
707 | #ifndef USE_DRV_CIRCLE |
||
708 | #define Circle(x, y, radius) Bevel(x, y, x, y, radius) |
||
709 | #else |
||
710 | WORD Circle(SHORT x, SHORT y, SHORT radius); |
||
711 | #endif |
||
712 | |||
713 | /********************************************************************* |
||
714 | * Macro: SetBevelDrawType(type) |
||
715 | * |
||
716 | * Overview: This macro sets the fill bevel type to be drawn. |
||
717 | * |
||
718 | * Input: type - is set using the following. |
||
719 | * - DRAWFULLBEVEL to draw the full shape |
||
720 | * - DRAWTOPBEVEL to draw the upper half portion |
||
721 | * - DRAWBOTTOMBEVEL to draw the lower half portion |
||
722 | * |
||
723 | * Output: none |
||
724 | * |
||
725 | * Side Effects: none |
||
726 | * |
||
727 | ********************************************************************/ |
||
728 | #define SetBevelDrawType(type) (_bevelDrawType = type) |
||
729 | |||
730 | /********************************************************************* |
||
731 | * Function: WORD Bevel(SHORT x1, SHORT y1, SHORT x2, SHORT y2, SHORT rad) |
||
732 | * |
||
733 | * Overview: Draws a beveled figure on the screen. |
||
734 | * For a pure circular object x1 = x2 and y1 = y2. |
||
735 | * For a rectangular object radius = 0. |
||
736 | * |
||
737 | * Input: x1 - x coordinate position of the upper left center of the circle that |
||
738 | * draws the rounded corners. |
||
739 | * y1 - y coordinate position of the upper left center of the circle that |
||
740 | * draws the rounded corners. |
||
741 | * x2 - x coordinate position of the lower right center of the circle that |
||
742 | * draws the rounded corners. |
||
743 | * y2 - y coordinate position of the lower right center of the circle that |
||
744 | * draws the rounded corners. |
||
745 | * rad - defines the redius of the circle, that draws the rounded corners. |
||
746 | * |
||
747 | * Output: For NON-Blocking configuration: |
||
748 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
749 | * - Returns 1 when the shape is completely drawn. |
||
750 | * For Blocking configuration: |
||
751 | * - Always return 1. |
||
752 | * |
||
753 | * |
||
754 | * Side Effects: none |
||
755 | * |
||
756 | ********************************************************************/ |
||
757 | WORD Bevel(SHORT x1, SHORT y1, SHORT x2, SHORT y2, SHORT rad); |
||
758 | |||
759 | /********************************************************************* |
||
760 | * Function: WORD FillBevel(SHORT x1, SHORT y1, SHORT x2, SHORT y2, SHORT rad) |
||
761 | * |
||
762 | * Overview: Draws a filled beveled figure on the screen. |
||
763 | * For a filled circular object x1 = x2 and y1 = y2. |
||
764 | * For a filled rectangular object radius = 0. |
||
765 | * |
||
766 | * Input: x1 - x coordinate position of the upper left center of the circle that |
||
767 | * draws the rounded corners. |
||
768 | * y1 - y coordinate position of the upper left center of the circle that |
||
769 | * draws the rounded corners. |
||
770 | * x2 - x coordinate position of the lower right center of the circle that |
||
771 | * draws the rounded corners. |
||
772 | * y2 - y coordinate position of the lower right center of the circle that |
||
773 | * draws the rounded corners. |
||
774 | * rad - defines the redius of the circle, that draws the rounded corners. |
||
775 | * |
||
776 | * Output: For NON-Blocking configuration: |
||
777 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
778 | * - Returns 1 when the shape is completely drawn. |
||
779 | * For Blocking configuration: |
||
780 | * - Always return 1. |
||
781 | * |
||
782 | * Side Effects: none |
||
783 | * |
||
784 | ********************************************************************/ |
||
785 | WORD FillBevel(SHORT x1, SHORT y1, SHORT x2, SHORT y2, SHORT rad); |
||
786 | |||
787 | /********************************************************************* |
||
788 | * Macro: FillCircle(SHORT x1, SHORT y1, SHORT rad) |
||
789 | * |
||
790 | * Overview: This macro draws a filled circle. Uses the FillBevel() function. |
||
791 | * |
||
792 | * Input: x1 - x coordinate position of the center of the circle. |
||
793 | * y1 - y coordinate position of the center of the circle. |
||
794 | * rad - defines the redius of the circle. |
||
795 | * |
||
796 | * Output: For NON-Blocking configuration: |
||
797 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
798 | * - Returns 1 when the shape is completely drawn. |
||
799 | * For Blocking configuration: |
||
800 | * - Always return 1. |
||
801 | * |
||
802 | * Side Effects: none |
||
803 | * |
||
804 | ********************************************************************/ |
||
805 | #ifndef USE_DRV_FILLCIRCLE |
||
806 | #define FillCircle(x1, y1, rad) FillBevel(x1, y1, x1, y1, rad) |
||
807 | #endif // end of USE_DRV_FILLCIRCLE |
||
808 | |||
809 | /********************************************************************* |
||
810 | * Macro: Rectangle(left, top, right, bottom) |
||
811 | * |
||
812 | * Overview: This macro draws a rectangle with the given left, |
||
813 | * top and right, bottom corners. Current line type is used. |
||
814 | * |
||
815 | * Input: left - x position of the left top corner. |
||
816 | * top - y position of the left top corner. |
||
817 | * right - x position of the right bottom corner. |
||
818 | * bottom - y position of the right bottom corner. |
||
819 | * |
||
820 | * Output: For NON-Blocking configuration: |
||
821 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
822 | * - Returns 1 when the shape is completely drawn. |
||
823 | * For Blocking configuration: |
||
824 | * - Always return 1. |
||
825 | * |
||
826 | * Side Effects: none |
||
827 | * |
||
828 | ********************************************************************/ |
||
829 | #define Rectangle(left, top, right, bottom) Bevel(left, top, right, bottom, 0) |
||
830 | |||
831 | /********************************************************************* |
||
832 | * Function: WORD DrawPoly(SHORT numPoints, SHORT* polyPoints) |
||
833 | * |
||
834 | * Overview: This function draws a polygon with the current line |
||
835 | * type using the given number of points. The polygon points |
||
836 | * are stored in an array arranged in the following order: |
||
837 | * <PRE> |
||
838 | * SHORT polyPoints[numPoints] = {x0, y0, x1, y1, x2, y2
xn, yn}; |
||
839 | * Where n = numPoints - 1 |
||
840 | * </PRE> |
||
841 | * |
||
842 | * Input: numPoints - Defines the number of points in the polygon. |
||
843 | * polyPoints - Pointer to the array of polygon points. |
||
844 | * |
||
845 | * Output: For NON-Blocking configuration: |
||
846 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
847 | * - Returns 1 when the shape is completely drawn. |
||
848 | * For Blocking configuration: |
||
849 | * - Always return 1. |
||
850 | * |
||
851 | * |
||
852 | * Side Effects: none |
||
853 | * |
||
854 | ********************************************************************/ |
||
855 | WORD DrawPoly(SHORT numPoints, SHORT *polyPoints); |
||
856 | |||
857 | /********************************************************************* |
||
858 | * Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) |
||
859 | * |
||
860 | * Overview: This function draws a bar given the left, top and right, |
||
861 | * bottom corners with the current color. |
||
862 | * |
||
863 | * Input: left - x position of the left top corner. |
||
864 | * top - y position of the left top corner. |
||
865 | * right - x position of the right bottom corner. |
||
866 | * bottom - y position of the right bottom corner. |
||
867 | * |
||
868 | * Output: For NON-Blocking configuration: |
||
869 | * - Returns 0 when device is busy and the shape is not yet completely drawn. |
||
870 | * - Returns 1 when the shape is completely drawn. |
||
871 | * For Blocking configuration: |
||
872 | * - Always return 1. |
||
873 | * |
||
874 | * |
||
875 | * Side Effects: none |
||
876 | * |
||
877 | ********************************************************************/ |
||
878 | WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom); |
||
879 | |||
880 | /********************************************************************* |
||
881 | * Function: void ClearDevice(void) |
||
882 | * |
||
883 | * Overview: This function clears the screen with the current color |
||
884 | * and sets the graphic cursor position to (0, 0). |
||
885 | * Clipping is NOT supported by ClearDevice(). |
||
886 | * |
||
887 | * Input: none |
||
888 | * |
||
889 | * Output: none |
||
890 | * |
||
891 | * Example: |
||
892 | * <CODE> |
||
893 | * void ClearScreen(void) |
||
894 | * { |
||
895 | * SetColor(WHITE); // set color to WHITE |
||
896 | * ClearDevice(); // set screen to all WHITE |
||
897 | * } |
||
898 | * </CODE> |
||
899 | * |
||
900 | * Side Effects: none |
||
901 | * |
||
902 | ********************************************************************/ |
||
903 | void ClearDevice(void); |
||
904 | |||
905 | /********************************************************************* |
||
906 | * Function: WORD PutImage(SHORT left, SHORT top, void* bitmap, BYTE stretch) |
||
907 | * |
||
908 | * Overview: This function outputs image starting from left,top coordinates. |
||
909 | * |
||
910 | * Input: left - x coordinate position of the left top corner. |
||
911 | * top - y coordinate position of the left top corner. |
||
912 | * bitmap - pointer to the bitmap. |
||
913 | * stretch - The image stretch factor. |
||
914 | * |
||
915 | * Output: For NON-Blocking configuration: |
||
916 | * - Returns 0 when device is busy and the image is not yet completely drawn. |
||
917 | * - Returns 1 when the image is completely drawn. |
||
918 | * For Blocking configuration: |
||
919 | * - Always return 1. |
||
920 | * |
||
921 | * |
||
922 | * Side Effects: none |
||
923 | * |
||
924 | ********************************************************************/ |
||
925 | WORD PutImage(SHORT left, SHORT top, void *bitmap, BYTE stretch); |
||
926 | |||
927 | /********************************************************************* |
||
928 | * Function: SHORT GetImageWidth(void* bitmap) |
||
929 | * |
||
930 | * Overview: This function returns the image width. |
||
931 | * |
||
932 | * Input: bitmap - Pointer to the bitmap. |
||
933 | * |
||
934 | * Output: Returns the image width in pixels. |
||
935 | * |
||
936 | * Side Effects: none |
||
937 | * |
||
938 | ********************************************************************/ |
||
939 | SHORT GetImageWidth(void *bitmap); |
||
940 | |||
941 | /********************************************************************* |
||
942 | * Function: SHORT GetImageHeight(void* bitmap) |
||
943 | * |
||
944 | * Overview: This function returns the image height. |
||
945 | * |
||
946 | * Input: bitmap - Pointer to the bitmap. |
||
947 | * |
||
948 | * Output: Returns the image height in pixels. |
||
949 | * |
||
950 | * Side Effects: none |
||
951 | * |
||
952 | ********************************************************************/ |
||
953 | SHORT GetImageHeight(void *bitmap); |
||
954 | |||
955 | /********************************************************************* |
||
956 | * Function: WORD ExternalMemoryCallback(EXTDATA* memory, LONG offset, WORD nCount, void* buffer) |
||
957 | * |
||
958 | * Overview: This function must be implemented in the application. |
||
959 | * The library will call this function each time when |
||
960 | * the external memory data will be required. The application |
||
961 | * must copy requested bytes quantity into the buffer provided. |
||
962 | * Data start address in external memory is a sum of the address |
||
963 | * in EXTDATA structure and offset. |
||
964 | * |
||
965 | * Input: memory - Pointer to the external memory bitmap or font structures |
||
966 | * (FONT_EXTERNAL or BITMAP_EXTERNAL). |
||
967 | * offset - Data offset. |
||
968 | * nCount - Number of bytes to be transferred into the buffer. |
||
969 | * buffer - Pointer to the buffer. |
||
970 | * |
||
971 | * Output: Returns the number of bytes were transferred. |
||
972 | * |
||
973 | * Example: |
||
974 | * <CODE> |
||
975 | * // If there are several memories in the system they can be selected by IDs. |
||
976 | * // In this example, ID for memory device used is assumed to be 0. |
||
977 | * #define X_MEMORY 0 |
||
978 | * |
||
979 | * WORD ExternalMemoryCallback(EXTDATA* memory, LONG offset, WORD nCount, void* buffer) { |
||
980 | * int i; |
||
981 | * long address; |
||
982 | * |
||
983 | * // Address of the requested data is a start address of the object referred by EXTDATA structure plus offset |
||
984 | * address = memory->address+offset; |
||
985 | * |
||
986 | * if(memory->ID == X_MEMORY){ |
||
987 | * // MemoryXReadByte() is some function implemented to access external memory. |
||
988 | * // Implementation will be specific to the memory used. In this example |
||
989 | * // it reads byte each time it is called. |
||
990 | * i = 0; |
||
991 | * while (i < nCount) { |
||
992 | * (BYTE*)buffer = MemoryXReadByte(address++); |
||
993 | * i++; |
||
994 | * } |
||
995 | * } |
||
996 | * // return the actual number of bytes retrieved |
||
997 | * return (i); |
||
998 | * } |
||
999 | * </CODE> |
||
1000 | * |
||
1001 | * Side Effects: none |
||
1002 | * |
||
1003 | ********************************************************************/ |
||
1004 | WORD ExternalMemoryCallback(EXTDATA *memory, LONG offset, WORD nCount, void *buffer); |
||
1005 | #endif // _PRIMITIVE_H |
Powered by WebSVN v2.8.3