1 //*****************************************************************************
\r
3 // grlib.h - Prototypes for the low level primitives provided by the graphics
\r
6 // Copyright (c) 2007-2008 Luminary Micro, Inc. All rights reserved.
\r
8 // Software License Agreement
\r
10 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
\r
11 // exclusively on LMI's microcontroller products.
\r
13 // The software is owned by LMI and/or its suppliers, and is protected under
\r
14 // applicable copyright laws. All rights are reserved. You may not combine
\r
15 // this software with "viral" open-source software in order to form a larger
\r
16 // program. Any use in violation of the foregoing restrictions may subject
\r
17 // the user to criminal sanctions under applicable laws, as well as to civil
\r
18 // liability for the breach of the terms and conditions of this license.
\r
20 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
21 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
23 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
24 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
26 // This is part of revision 2523 of the Stellaris Graphics Library.
\r
28 //*****************************************************************************
\r
33 //*****************************************************************************
\r
35 //! \addtogroup primitives_api
\r
38 //*****************************************************************************
\r
40 //*****************************************************************************
\r
42 // If building with a C++ compiler, make all of the definitions in this header
\r
43 // have a C binding.
\r
45 //*****************************************************************************
\r
51 //*****************************************************************************
\r
53 //! This structure defines the extents of a rectangle. All points greater than
\r
54 //! or equal to the minimum and less than or equal to the maximum are part of
\r
57 //*****************************************************************************
\r
61 //! The minimum X coordinate of the rectangle.
\r
66 //! The minimum Y coordinate of the rectangle.
\r
71 //! The maximum X coordinate of the rectangle.
\r
76 //! The maximum Y coordinate of the rectangle.
\r
82 //*****************************************************************************
\r
84 //! This structure defines the characteristics of a display driver.
\r
86 //*****************************************************************************
\r
90 //! The size of this structure.
\r
95 //! A pointer to display driver-specific data.
\r
97 void *pvDisplayData;
\r
100 //! The width of this display.
\r
102 unsigned short usWidth;
\r
105 //! The height of this display.
\r
107 unsigned short usHeight;
\r
110 //! A pointer to the function to draw a pixel on this display.
\r
112 void (*pfnPixelDraw)(void *pvDisplayData, long lX, long lY,
\r
113 unsigned long ulValue);
\r
116 //! A pointer to the function to draw multiple pixels on this display.
\r
118 void (*pfnPixelDrawMultiple)(void *pvDisplayData, long lX, long lY,
\r
119 long lX0, long lCount, long lBPP,
\r
120 const unsigned char *pucData,
\r
121 const unsigned char *pucPalette);
\r
124 //! A pointer to the function to draw a horizontal line on this display.
\r
126 void (*pfnLineDrawH)(void *pvDisplayData, long lX1, long lX2, long lY,
\r
127 unsigned long ulValue);
\r
130 //! A pointer to the function to draw a vertical line on this display.
\r
132 void (*pfnLineDrawV)(void *pvDisplayData, long lX, long lY1, long lY2,
\r
133 unsigned long ulValue);
\r
136 //! A pointer to the function to draw a filled rectangle on this display.
\r
138 void (*pfnRectFill)(void *pvDisplayData, const tRectangle *pRect,
\r
139 unsigned long ulValue);
\r
142 //! A pointer to the function to translate 24-bit RGB colors to
\r
143 //! display-specific colors.
\r
145 unsigned long (*pfnColorTranslate)(void *pvDisplayData,
\r
146 unsigned long ulValue);
\r
149 //! A pointer to the function to flush any cached drawing operations on
\r
152 void (*pfnFlush)(void *pvDisplayData);
\r
156 //*****************************************************************************
\r
158 //! This structure describes a font used for drawing text onto the screen.
\r
160 //*****************************************************************************
\r
164 //! The format of the font. Can be one of FONT_FMT_UNCOMPRESSED or
\r
165 //! FONT_FMT_PIXEL_RLE.
\r
167 unsigned char ucFormat;
\r
170 //! The maximum width of a character; this is the width of the widest
\r
171 //! character in the font, though any individual character may be narrower
\r
172 //! than this width.
\r
174 unsigned char ucMaxWidth;
\r
177 //! The height of the character cell; this may be taller than the font data
\r
178 //! for the characters (to provide inter-line spacing).
\r
180 unsigned char ucHeight;
\r
183 //! The offset between the top of the character cell and the baseline of
\r
184 //! the glyph. The baseline is the bottom row of a capital letter, below
\r
185 //! which only the descenders of the lower case letters occur.
\r
187 unsigned char ucBaseline;
\r
190 //! The offset within pucData to the data for each character in the font.
\r
192 unsigned short pusOffset[96];
\r
195 //! A pointer to the data for the font.
\r
197 const unsigned char *pucData;
\r
201 //*****************************************************************************
\r
203 //! Indicates that the font data is stored in an uncompressed format.
\r
205 //*****************************************************************************
\r
206 #define FONT_FMT_UNCOMPRESSED 0x00
\r
208 //*****************************************************************************
\r
210 //! Indicates that the font data is stored using a pixel-based RLE format.
\r
212 //*****************************************************************************
\r
213 #define FONT_FMT_PIXEL_RLE 0x01
\r
215 //*****************************************************************************
\r
217 //! Indicates that the image data is not compressed and represents each pixel
\r
218 //! with a single bit.
\r
220 //*****************************************************************************
\r
221 #define IMAGE_FMT_1BPP_UNCOMP 0x01
\r
223 //*****************************************************************************
\r
225 //! Indicates that the image data is not compressed and represents each pixel
\r
226 //! with four bits.
\r
228 //*****************************************************************************
\r
229 #define IMAGE_FMT_4BPP_UNCOMP 0x04
\r
231 //*****************************************************************************
\r
233 //! Indicates that the image data is not compressed and represents each pixel
\r
234 //! with eight bits.
\r
236 //*****************************************************************************
\r
237 #define IMAGE_FMT_8BPP_UNCOMP 0x08
\r
239 //*****************************************************************************
\r
241 //! Indicates that the image data is compressed and represents each pixel with
\r
244 //*****************************************************************************
\r
245 #define IMAGE_FMT_1BPP_COMP 0x81
\r
247 //*****************************************************************************
\r
249 //! Indicates that the image data is compressed and represents each pixel with
\r
252 //*****************************************************************************
\r
253 #define IMAGE_FMT_4BPP_COMP 0x84
\r
255 //*****************************************************************************
\r
257 //! Indicates that the image data is compressed and represents each pixel with
\r
260 //*****************************************************************************
\r
261 #define IMAGE_FMT_8BPP_COMP 0x88
\r
263 //*****************************************************************************
\r
265 //! This structure defines a drawing context to be used to draw onto the
\r
266 //! screen. Multiple drawing contexts may exist at any time.
\r
268 //*****************************************************************************
\r
272 //! The size of this structure.
\r
277 //! The screen onto which drawing operations are performed.
\r
279 const tDisplay *pDisplay;
\r
282 //! The clipping region to be used when drawing onto the screen.
\r
284 tRectangle sClipRegion;
\r
287 //! The color used to draw primitives onto the screen.
\r
289 unsigned long ulForeground;
\r
292 //! The background color used to draw primitives onto the screen.
\r
294 unsigned long ulBackground;
\r
297 //! The font used to render text onto the screen.
\r
299 const tFont *pFont;
\r
303 //*****************************************************************************
\r
305 //! Sets the background color to be used.
\r
307 //! \param pContext is a pointer to the drawing context to modify.
\r
308 //! \param ulValue is the 24-bit RGB color to be used.
\r
310 //! This function sets the background color to be used for drawing operations
\r
311 //! in the specified drawing context.
\r
315 //*****************************************************************************
\r
316 #define GrContextBackgroundSet(pContext, ulValue) \
\r
319 tContext *pC = pContext; \
\r
320 pC->ulBackground = DpyColorTranslate(pC->pDisplay, ulValue); \
\r
324 //*****************************************************************************
\r
326 //! Sets the background color to be used.
\r
328 //! \param pContext is a pointer to the drawing context to modify.
\r
329 //! \param ulValue is the display driver-specific color to be used.
\r
331 //! This function sets the background color to be used for drawing operations
\r
332 //! in the specified drawing context, using a color that has been previously
\r
333 //! translated to a driver-specific color (for example, via
\r
334 //! DpyColorTranslate()).
\r
338 //*****************************************************************************
\r
339 #define GrContextBackgroundSetTranslated(pContext, ulValue) \
\r
342 tContext *pC = pContext; \
\r
343 pC->ulBackground = ulValue; \
\r
347 //*****************************************************************************
\r
349 //! Gets the width of the display being used by this drawing context.
\r
351 //! \param pContext is a pointer to the drawing context to query.
\r
353 //! This function returns the width of the display that is being used by this
\r
354 //! drawing context.
\r
356 //! \return Returns the width of the display in pixels.
\r
358 //*****************************************************************************
\r
359 #define GrContextDpyWidthGet(pContext) \
\r
360 (DpyWidthGet((pContext)->pDisplay))
\r
362 //*****************************************************************************
\r
364 //! Gets the height of the display being used by this drawing context.
\r
366 //! \param pContext is a pointer to the drawing context to query.
\r
368 //! This function returns the height of the display that is being used by this
\r
369 //! drawing context.
\r
371 //! \return Returns the height of the display in pixels.
\r
373 //*****************************************************************************
\r
374 #define GrContextDpyHeightGet(pContext) \
\r
375 (DpyHeightGet((pContext)->pDisplay))
\r
377 //*****************************************************************************
\r
379 //! Sets the font to be used.
\r
381 //! \param pContext is a pointer to the drawing context to modify.
\r
382 //! \param pFnt is a pointer to the font to be used.
\r
384 //! This function sets the font to be used for string drawing operations in the
\r
385 //! specified drawing context.
\r
389 //*****************************************************************************
\r
390 #define GrContextFontSet(pContext, pFnt) \
\r
393 tContext *pC = pContext; \
\r
394 const tFont *pF = pFnt; \
\r
399 //*****************************************************************************
\r
401 //! Sets the foreground color to be used.
\r
403 //! \param pContext is a pointer to the drawing context to modify.
\r
404 //! \param ulValue is the 24-bit RGB color to be used.
\r
406 //! This function sets the color to be used for drawing operations in the
\r
407 //! specified drawing context.
\r
411 //*****************************************************************************
\r
412 #define GrContextForegroundSet(pContext, ulValue) \
\r
415 tContext *pC = pContext; \
\r
416 pC->ulForeground = DpyColorTranslate(pC->pDisplay, ulValue); \
\r
420 //*****************************************************************************
\r
422 //! Sets the foreground color to be used.
\r
424 //! \param pContext is a pointer to the drawing context to modify.
\r
425 //! \param ulValue is the display driver-specific color to be used.
\r
427 //! This function sets the foreground color to be used for drawing operations
\r
428 //! in the specified drawing context, using a color that has been previously
\r
429 //! translated to a driver-specific color (for example, via
\r
430 //! DpyColorTranslate()).
\r
434 //*****************************************************************************
\r
435 #define GrContextForegroundSetTranslated(pContext, ulValue) \
\r
438 tContext *pC = pContext; \
\r
439 pC->ulForeground = ulValue; \
\r
443 //*****************************************************************************
\r
445 //! Flushes any cached drawing operations.
\r
447 //! \param pContext is a pointer to the drawing context to use.
\r
449 //! This function flushes any cached drawing operations. For display drivers
\r
450 //! that draw into a local frame buffer before writing to the actual display,
\r
451 //! calling this function will cause the display to be updated to match the
\r
452 //! contents of the local frame buffer.
\r
456 //*****************************************************************************
\r
457 #define GrFlush(pContext) \
\r
460 const tContext *pC = pContext; \
\r
461 DpyFlush(pC->pDisplay); \
\r
465 //*****************************************************************************
\r
467 //! Gets the baseline of a font.
\r
469 //! \param pFont is a pointer to the font to query.
\r
471 //! This function determines the baseline position of a font. The baseline is
\r
472 //! the offset between the top of the font and the bottom of the capital
\r
473 //! letters. The only font data that exists below the baseline are the
\r
474 //! descenders on some lower-case letters (such as ``y'').
\r
476 //! \return Returns the baseline of the font, in pixels.
\r
478 //*****************************************************************************
\r
479 #define GrFontBaselineGet(pFont) \
\r
480 ((pFont)->ucBaseline)
\r
482 //*****************************************************************************
\r
484 //! Gets the height of a font.
\r
486 //! \param pFont is a pointer to the font to query.
\r
488 //! This function determines the height of a font. The height is the offset
\r
489 //! between the top of the font and the bottom of the font, including any
\r
490 //! ascenders and descenders.
\r
492 //! \return Returns the height of the font, in pixels.
\r
494 //*****************************************************************************
\r
495 #define GrFontHeightGet(pFont) \
\r
496 ((pFont)->ucHeight)
\r
498 //*****************************************************************************
\r
500 //! Gets the maximum width of a font.
\r
502 //! \param pFont is a pointer to the font to query.
\r
504 //! This function determines the maximum width of a font. The maximum width is
\r
505 //! the width of the widest individual character in the font.
\r
507 //! \return Returns the maximum width of the font, in pixels.
\r
509 //*****************************************************************************
\r
510 #define GrFontMaxWidthGet(pFont) \
\r
511 ((pFont)->ucMaxWidth)
\r
513 //*****************************************************************************
\r
515 //! Gets the number of colors in an image.
\r
517 //! \param pucImage is a pointer to the image to query.
\r
519 //! This function determines the number of colors in the palette of an image.
\r
520 //! This is only valid for 4bpp and 8bpp images; 1bpp images do not contain a
\r
523 //! \return Returns the number of colors in the image.
\r
525 //*****************************************************************************
\r
526 #define GrImageColorsGet(pucImage) \
\r
527 (((unsigned char *)pucImage)[5] + 1)
\r
529 //*****************************************************************************
\r
531 //! Gets the height of an image.
\r
533 //! \param pucImage is a pointer to the image to query.
\r
535 //! This function determines the height of an image in pixels.
\r
537 //! \return Returns the height of the image in pixels.
\r
539 //*****************************************************************************
\r
540 #define GrImageHeightGet(pucImage) \
\r
541 (*(unsigned short *)(pucImage + 3))
\r
543 //*****************************************************************************
\r
545 //! Gets the width of an image.
\r
547 //! \param pucImage is a pointer to the image to query.
\r
549 //! This function determines the width of an image in pixels.
\r
551 //! \return Returns the width of the image in pixels.
\r
553 //*****************************************************************************
\r
554 #define GrImageWidthGet(pucImage) \
\r
555 (*(unsigned short *)(pucImage + 1))
\r
557 //*****************************************************************************
\r
559 //! Determines the size of the buffer for a 1 BPP off-screen image.
\r
561 //! \param lWidth is the width of the image in pixels.
\r
562 //! \param lHeight is the height of the image in pixels.
\r
564 //! This function determines the size of the memory buffer required to hold a
\r
565 //! 1 BPP off-screen image of the specified geometry.
\r
567 //! \return Returns the number of bytes required by the image.
\r
569 //*****************************************************************************
\r
570 #define GrOffScreen1BPPSize(lWidth, lHeight) \
\r
571 (5 + (((lWidth + 7) / 8) * lHeight))
\r
573 //*****************************************************************************
\r
575 //! Determines the size of the buffer for a 4 BPP off-screen image.
\r
577 //! \param lWidth is the width of the image in pixels.
\r
578 //! \param lHeight is the height of the image in pixels.
\r
580 //! This function determines the size of the memory buffer required to hold a
\r
581 //! 4 BPP off-screen image of the specified geometry.
\r
583 //! \return Returns the number of bytes required by the image.
\r
585 //*****************************************************************************
\r
586 #define GrOffScreen4BPPSize(lWidth, lHeight) \
\r
587 (6 + (16 * 3) + (((lWidth + 1) / 2) * lHeight))
\r
589 //*****************************************************************************
\r
591 //! Determines the size of the buffer for an 8 BPP off-screen image.
\r
593 //! \param lWidth is the width of the image in pixels.
\r
594 //! \param lHeight is the height of the image in pixels.
\r
596 //! This function determines the size of the memory buffer required to hold an
\r
597 //! 8 BPP off-screen image of the specified geometry.
\r
599 //! \return Returns the number of bytes required by the image.
\r
601 //*****************************************************************************
\r
602 #define GrOffScreen8BPPSize(lWidth, lHeight) \
\r
603 (6 + (256 * 3) + (lWidth * lHeight))
\r
605 //*****************************************************************************
\r
609 //! \param pContext is a pointer to the drawing context to use.
\r
610 //! \param lX is the X coordinate of the pixel.
\r
611 //! \param lY is the Y coordinate of the pixel.
\r
613 //! This function draws a pixel if it resides within the clipping region.
\r
617 //*****************************************************************************
\r
618 #define GrPixelDraw(pContext, lX, lY) \
\r
621 const tContext *pC = pContext; \
\r
622 if((lX >= pC->sClipRegion.sXMin) && \
\r
623 (lX <= pC->sClipRegion.sXMax) && \
\r
624 (lY >= pC->sClipRegion.sYMin) && \
\r
625 (lY <= pC->sClipRegion.sYMax)) \
\r
627 DpyPixelDraw(pC->pDisplay, lX, lY, pC->ulForeground); \
\r
632 //*****************************************************************************
\r
634 //! Gets the baseline of a string.
\r
636 //! \param pContext is a pointer to the drawing context to query.
\r
638 //! This function determines the baseline position of a string. The baseline
\r
639 //! is the offset between the top of the string and the bottom of the capital
\r
640 //! letters. The only string data that exists below the baseline are the
\r
641 //! descenders on some lower-case letters (such as ``y'').
\r
643 //! \return Returns the baseline of the string, in pixels.
\r
645 //*****************************************************************************
\r
646 #define GrStringBaselineGet(pContext) \
\r
647 ((pContext)->pFont->ucBaseline)
\r
649 //*****************************************************************************
\r
651 //! Draws a centered string.
\r
653 //! \param pContext is a pointer to the drawing context to use.
\r
654 //! \param pcString is a pointer to the string to be drawn.
\r
655 //! \param lLength is the number of characters from the string that should be
\r
656 //! drawn on the screen.
\r
657 //! \param lX is the X coordinate of the center of the string position on the
\r
659 //! \param lY is the Y coordinate of the center of the string position on the
\r
661 //! \param bOpaque is \b true if the background of each character should be
\r
662 //! drawn and \b false if it should not (leaving the background as is).
\r
664 //! This function draws a string of test on the screen centered upon the
\r
665 //! provided position. The \e lLength parameter allows a portion of the
\r
666 //! string to be examined without having to insert a NULL character at the
\r
667 //! stopping point (which would not be possible if the string was located in
\r
668 //! flash); specifying a length of -1 will cause the entire string to be
\r
669 //! rendered (subject to clipping).
\r
673 //*****************************************************************************
\r
674 #define GrStringDrawCentered(pContext, pcString, lLength, lX, lY, bOpaque) \
\r
677 const tContext *pC = pContext; \
\r
678 const char *pcStr = pcString; \
\r
680 GrStringDraw(pC, pcStr, lLength, \
\r
681 (lX) - (GrStringWidthGet(pC, pcStr, lLength) / 2), \
\r
682 (lY) - (pC->pFont->ucBaseline / 2), bOpaque); \
\r
686 //*****************************************************************************
\r
688 //! Gets the height of a string.
\r
690 //! \param pContext is a pointer to the drawing context to query.
\r
692 //! This function determines the height of a string. The height is the offset
\r
693 //! between the top of the string and the bottom of the string, including any
\r
694 //! ascenders and descenders. Note that this will not account for the case
\r
695 //! where the string in question does not have any characters that use
\r
696 //! descenders but the font in the drawing context does contain characters with
\r
699 //! \return Returns the height of the string, in pixels.
\r
701 //*****************************************************************************
\r
702 #define GrStringHeightGet(pContext) \
\r
703 ((pContext)->pFont->ucHeight)
\r
705 //*****************************************************************************
\r
707 //! Gets the maximum width of a character in a string.
\r
709 //! \param pContext is a pointer to the drawing context to query.
\r
711 //! This function determines the maximum width of a character in a string. The
\r
712 //! maximum width is the width of the widest individual character in the font
\r
713 //! used to render the string, which may be wider than the widest character
\r
714 //! that is used to render a particular string.
\r
716 //! \return Returns the maximum width of a character in a string, in pixels.
\r
718 //*****************************************************************************
\r
719 #define GrStringMaxWidthGet(pContext) \
\r
720 ((pContext)->pFont->ucMaxWidth)
\r
722 //*****************************************************************************
\r
724 // A set of color definitions. This set is the subset of the X11 colors (from
\r
725 // rgb.txt) that are supported by typical web browsers.
\r
727 //*****************************************************************************
\r
728 #define ClrAliceBlue 0x00F0F8FF
\r
729 #define ClrAntiqueWhite 0x00FAEBD7
\r
730 #define ClrAqua 0x0000FFFF
\r
731 #define ClrAquamarine 0x007FFFD4
\r
732 #define ClrAzure 0x00F0FFFF
\r
733 #define ClrBeige 0x00F5F5DC
\r
734 #define ClrBisque 0x00FFE4C4
\r
735 #define ClrBlack 0x00000000
\r
736 #define ClrBlanchedAlmond 0x00FFEBCD
\r
737 #define ClrBlue 0x000000FF
\r
738 #define ClrBlueViolet 0x008A2BE2
\r
739 #define ClrBrown 0x00A52A2A
\r
740 #define ClrBurlyWood 0x00DEB887
\r
741 #define ClrCadetBlue 0x005F9EA0
\r
742 #define ClrChartreuse 0x007FFF00
\r
743 #define ClrChocolate 0x00D2691E
\r
744 #define ClrCoral 0x00FF7F50
\r
745 #define ClrCornflowerBlue 0x006495ED
\r
746 #define ClrCornsilk 0x00FFF8DC
\r
747 #define ClrCrimson 0x00DC143C
\r
748 #define ClrCyan 0x0000FFFF
\r
749 #define ClrDarkBlue 0x0000008B
\r
750 #define ClrDarkCyan 0x00008B8B
\r
751 #define ClrDarkGoldenrod 0x00B8860B
\r
752 #define ClrDarkGray 0x00A9A9A9
\r
753 #define ClrDarkGreen 0x00006400
\r
754 #define ClrDarkKhaki 0x00BDB76B
\r
755 #define ClrDarkMagenta 0x008B008B
\r
756 #define ClrDarkOliveGreen 0x00556B2F
\r
757 #define ClrDarkOrange 0x00FF8C00
\r
758 #define ClrDarkOrchid 0x009932CC
\r
759 #define ClrDarkRed 0x008B0000
\r
760 #define ClrDarkSalmon 0x00E9967A
\r
761 #define ClrDarkSeaGreen 0x008FBC8F
\r
762 #define ClrDarkSlateBlue 0x00483D8B
\r
763 #define ClrDarkSlateGray 0x002F4F4F
\r
764 #define ClrDarkTurquoise 0x0000CED1
\r
765 #define ClrDarkViolet 0x009400D3
\r
766 #define ClrDeepPink 0x00FF1493
\r
767 #define ClrDeepSkyBlue 0x0000BFFF
\r
768 #define ClrDimGray 0x00696969
\r
769 #define ClrDodgerBlue 0x001E90FF
\r
770 #define ClrFireBrick 0x00B22222
\r
771 #define ClrFloralWhite 0x00FFFAF0
\r
772 #define ClrForestGreen 0x00228B22
\r
773 #define ClrFuchsia 0x00FF00FF
\r
774 #define ClrGainsboro 0x00DCDCDC
\r
775 #define ClrGhostWhite 0x00F8F8FF
\r
776 #define ClrGold 0x00FFD700
\r
777 #define ClrGoldenrod 0x00DAA520
\r
778 #define ClrGray 0x00808080
\r
779 #define ClrGreen 0x00008000
\r
780 #define ClrGreenYellow 0x00ADFF2F
\r
781 #define ClrHoneydew 0x00F0FFF0
\r
782 #define ClrHotPink 0x00FF69B4
\r
783 #define ClrIndianRed 0x00CD5C5C
\r
784 #define ClrIndigo 0x004B0082
\r
785 #define ClrIvory 0x00FFFFF0
\r
786 #define ClrKhaki 0x00F0E68C
\r
787 #define ClrLavender 0x00E6E6FA
\r
788 #define ClrLavenderBlush 0x00FFF0F5
\r
789 #define ClrLawnGreen 0x007CFC00
\r
790 #define ClrLemonChiffon 0x00FFFACD
\r
791 #define ClrLightBlue 0x00ADD8E6
\r
792 #define ClrLightCoral 0x00F08080
\r
793 #define ClrLightCyan 0x00E0FFFF
\r
794 #define ClrLightGoldenrodYellow 0x00FAFAD2
\r
795 #define ClrLightGreen 0x0090EE90
\r
796 #define ClrLightGrey 0x00D3D3D3
\r
797 #define ClrLightPink 0x00FFB6C1
\r
798 #define ClrLightSalmon 0x00FFA07A
\r
799 #define ClrLightSeaGreen 0x0020B2AA
\r
800 #define ClrLightSkyBlue 0x0087CEFA
\r
801 #define ClrLightSlateGray 0x00778899
\r
802 #define ClrLightSteelBlue 0x00B0C4DE
\r
803 #define ClrLightYellow 0x00FFFFE0
\r
804 #define ClrLime 0x0000FF00
\r
805 #define ClrLimeGreen 0x0032CD32
\r
806 #define ClrLinen 0x00FAF0E6
\r
807 #define ClrMagenta 0x00FF00FF
\r
808 #define ClrMaroon 0x00800000
\r
809 #define ClrMediumAquamarine 0x0066CDAA
\r
810 #define ClrMediumBlue 0x000000CD
\r
811 #define ClrMediumOrchid 0x00BA55D3
\r
812 #define ClrMediumPurple 0x009370DB
\r
813 #define ClrMediumSeaGreen 0x003CB371
\r
814 #define ClrMediumSlateBlue 0x007B68EE
\r
815 #define ClrMediumSpringGreen 0x0000FA9A
\r
816 #define ClrMediumTurquoise 0x0048D1CC
\r
817 #define ClrMediumVioletRed 0x00C71585
\r
818 #define ClrMidnightBlue 0x00191970
\r
819 #define ClrMintCream 0x00F5FFFA
\r
820 #define ClrMistyRose 0x00FFE4E1
\r
821 #define ClrMoccasin 0x00FFE4B5
\r
822 #define ClrNavajoWhite 0x00FFDEAD
\r
823 #define ClrNavy 0x00000080
\r
824 #define ClrOldLace 0x00FDF5E6
\r
825 #define ClrOlive 0x00808000
\r
826 #define ClrOliveDrab 0x006B8E23
\r
827 #define ClrOrange 0x00FFA500
\r
828 #define ClrOrangeRed 0x00FF4500
\r
829 #define ClrOrchid 0x00DA70D6
\r
830 #define ClrPaleGoldenrod 0x00EEE8AA
\r
831 #define ClrPaleGreen 0x0098FB98
\r
832 #define ClrPaleTurquoise 0x00AFEEEE
\r
833 #define ClrPaleVioletRed 0x00DB7093
\r
834 #define ClrPapayaWhip 0x00FFEFD5
\r
835 #define ClrPeachPuff 0x00FFDAB9
\r
836 #define ClrPeru 0x00CD853F
\r
837 #define ClrPink 0x00FFC0CB
\r
838 #define ClrPlum 0x00DDA0DD
\r
839 #define ClrPowderBlue 0x00B0E0E6
\r
840 #define ClrPurple 0x00800080
\r
841 #define ClrRed 0x00FF0000
\r
842 #define ClrRosyBrown 0x00BC8F8F
\r
843 #define ClrRoyalBlue 0x004169E1
\r
844 #define ClrSaddleBrown 0x008B4513
\r
845 #define ClrSalmon 0x00FA8072
\r
846 #define ClrSandyBrown 0x00F4A460
\r
847 #define ClrSeaGreen 0x002E8B57
\r
848 #define ClrSeashell 0x00FFF5EE
\r
849 #define ClrSienna 0x00A0522D
\r
850 #define ClrSilver 0x00C0C0C0
\r
851 #define ClrSkyBlue 0x0087CEEB
\r
852 #define ClrSlateBlue 0x006A5ACD
\r
853 #define ClrSlateGray 0x00708090
\r
854 #define ClrSnow 0x00FFFAFA
\r
855 #define ClrSpringGreen 0x0000FF7F
\r
856 #define ClrSteelBlue 0x004682B4
\r
857 #define ClrTan 0x00D2B48C
\r
858 #define ClrTeal 0x00008080
\r
859 #define ClrThistle 0x00D8BFD8
\r
860 #define ClrTomato 0x00FF6347
\r
861 #define ClrTurquoise 0x0040E0D0
\r
862 #define ClrViolet 0x00EE82EE
\r
863 #define ClrWheat 0x00F5DEB3
\r
864 #define ClrWhite 0x00FFFFFF
\r
865 #define ClrWhiteSmoke 0x00F5F5F5
\r
866 #define ClrYellow 0x00FFFF00
\r
867 #define ClrYellowGreen 0x009ACD32
\r
869 //*****************************************************************************
\r
871 // Masks and shifts to aid in color format translation by drivers.
\r
873 //*****************************************************************************
\r
874 #define ClrRedMask 0x00FF0000
\r
875 #define ClrRedShift 16
\r
876 #define ClrGreenMask 0x0000FF00
\r
877 #define ClrGreenShift 8
\r
878 #define ClrBlueMask 0x000000FF
\r
879 #define ClrBlueShift 0
\r
881 //*****************************************************************************
\r
883 // Prototypes for the predefined fonts in the graphics library. ..Cm.. is the
\r
884 // computer modern font, which is a serif font. ..Cmsc.. is the computer
\r
885 // modern small-caps font, which is also a serif font. ..Cmss.. is the
\r
886 // computer modern sans-serif font.
\r
888 //*****************************************************************************
\r
889 extern const tFont g_sFontCm12;
\r
890 extern const tFont g_sFontCm12b;
\r
891 extern const tFont g_sFontCm12i;
\r
892 extern const tFont g_sFontCm14;
\r
893 extern const tFont g_sFontCm14b;
\r
894 extern const tFont g_sFontCm14i;
\r
895 extern const tFont g_sFontCm16;
\r
896 extern const tFont g_sFontCm16b;
\r
897 extern const tFont g_sFontCm16i;
\r
898 extern const tFont g_sFontCm18;
\r
899 extern const tFont g_sFontCm18b;
\r
900 extern const tFont g_sFontCm18i;
\r
901 extern const tFont g_sFontCm20;
\r
902 extern const tFont g_sFontCm20b;
\r
903 extern const tFont g_sFontCm20i;
\r
904 extern const tFont g_sFontCm22;
\r
905 extern const tFont g_sFontCm22b;
\r
906 extern const tFont g_sFontCm22i;
\r
907 extern const tFont g_sFontCm24;
\r
908 extern const tFont g_sFontCm24b;
\r
909 extern const tFont g_sFontCm24i;
\r
910 extern const tFont g_sFontCm26;
\r
911 extern const tFont g_sFontCm26b;
\r
912 extern const tFont g_sFontCm26i;
\r
913 extern const tFont g_sFontCm28;
\r
914 extern const tFont g_sFontCm28b;
\r
915 extern const tFont g_sFontCm28i;
\r
916 extern const tFont g_sFontCm30;
\r
917 extern const tFont g_sFontCm30b;
\r
918 extern const tFont g_sFontCm30i;
\r
919 extern const tFont g_sFontCm32;
\r
920 extern const tFont g_sFontCm32b;
\r
921 extern const tFont g_sFontCm32i;
\r
922 extern const tFont g_sFontCm34;
\r
923 extern const tFont g_sFontCm34b;
\r
924 extern const tFont g_sFontCm34i;
\r
925 extern const tFont g_sFontCm36;
\r
926 extern const tFont g_sFontCm36b;
\r
927 extern const tFont g_sFontCm36i;
\r
928 extern const tFont g_sFontCm38;
\r
929 extern const tFont g_sFontCm38b;
\r
930 extern const tFont g_sFontCm38i;
\r
931 extern const tFont g_sFontCm40;
\r
932 extern const tFont g_sFontCm40b;
\r
933 extern const tFont g_sFontCm40i;
\r
934 extern const tFont g_sFontCm42;
\r
935 extern const tFont g_sFontCm42b;
\r
936 extern const tFont g_sFontCm42i;
\r
937 extern const tFont g_sFontCm44;
\r
938 extern const tFont g_sFontCm44b;
\r
939 extern const tFont g_sFontCm44i;
\r
940 extern const tFont g_sFontCm46;
\r
941 extern const tFont g_sFontCm46b;
\r
942 extern const tFont g_sFontCm46i;
\r
943 extern const tFont g_sFontCm48;
\r
944 extern const tFont g_sFontCm48b;
\r
945 extern const tFont g_sFontCm48i;
\r
946 extern const tFont g_sFontCmsc12;
\r
947 extern const tFont g_sFontCmsc14;
\r
948 extern const tFont g_sFontCmsc16;
\r
949 extern const tFont g_sFontCmsc18;
\r
950 extern const tFont g_sFontCmsc20;
\r
951 extern const tFont g_sFontCmsc22;
\r
952 extern const tFont g_sFontCmsc24;
\r
953 extern const tFont g_sFontCmsc26;
\r
954 extern const tFont g_sFontCmsc28;
\r
955 extern const tFont g_sFontCmsc30;
\r
956 extern const tFont g_sFontCmsc32;
\r
957 extern const tFont g_sFontCmsc34;
\r
958 extern const tFont g_sFontCmsc36;
\r
959 extern const tFont g_sFontCmsc38;
\r
960 extern const tFont g_sFontCmsc40;
\r
961 extern const tFont g_sFontCmsc42;
\r
962 extern const tFont g_sFontCmsc44;
\r
963 extern const tFont g_sFontCmsc46;
\r
964 extern const tFont g_sFontCmsc48;
\r
965 extern const tFont g_sFontCmss12;
\r
966 extern const tFont g_sFontCmss12b;
\r
967 extern const tFont g_sFontCmss12i;
\r
968 extern const tFont g_sFontCmss14;
\r
969 extern const tFont g_sFontCmss14b;
\r
970 extern const tFont g_sFontCmss14i;
\r
971 extern const tFont g_sFontCmss16;
\r
972 extern const tFont g_sFontCmss16b;
\r
973 extern const tFont g_sFontCmss16i;
\r
974 extern const tFont g_sFontCmss18;
\r
975 extern const tFont g_sFontCmss18b;
\r
976 extern const tFont g_sFontCmss18i;
\r
977 extern const tFont g_sFontCmss20;
\r
978 extern const tFont g_sFontCmss20b;
\r
979 extern const tFont g_sFontCmss20i;
\r
980 extern const tFont g_sFontCmss22;
\r
981 extern const tFont g_sFontCmss22b;
\r
982 extern const tFont g_sFontCmss22i;
\r
983 extern const tFont g_sFontCmss24;
\r
984 extern const tFont g_sFontCmss24b;
\r
985 extern const tFont g_sFontCmss24i;
\r
986 extern const tFont g_sFontCmss26;
\r
987 extern const tFont g_sFontCmss26b;
\r
988 extern const tFont g_sFontCmss26i;
\r
989 extern const tFont g_sFontCmss28;
\r
990 extern const tFont g_sFontCmss28b;
\r
991 extern const tFont g_sFontCmss28i;
\r
992 extern const tFont g_sFontCmss30;
\r
993 extern const tFont g_sFontCmss30b;
\r
994 extern const tFont g_sFontCmss30i;
\r
995 extern const tFont g_sFontCmss32;
\r
996 extern const tFont g_sFontCmss32b;
\r
997 extern const tFont g_sFontCmss32i;
\r
998 extern const tFont g_sFontCmss34;
\r
999 extern const tFont g_sFontCmss34b;
\r
1000 extern const tFont g_sFontCmss34i;
\r
1001 extern const tFont g_sFontCmss36;
\r
1002 extern const tFont g_sFontCmss36b;
\r
1003 extern const tFont g_sFontCmss36i;
\r
1004 extern const tFont g_sFontCmss38;
\r
1005 extern const tFont g_sFontCmss38b;
\r
1006 extern const tFont g_sFontCmss38i;
\r
1007 extern const tFont g_sFontCmss40;
\r
1008 extern const tFont g_sFontCmss40b;
\r
1009 extern const tFont g_sFontCmss40i;
\r
1010 extern const tFont g_sFontCmss42;
\r
1011 extern const tFont g_sFontCmss42b;
\r
1012 extern const tFont g_sFontCmss42i;
\r
1013 extern const tFont g_sFontCmss44;
\r
1014 extern const tFont g_sFontCmss44b;
\r
1015 extern const tFont g_sFontCmss44i;
\r
1016 extern const tFont g_sFontCmss46;
\r
1017 extern const tFont g_sFontCmss46b;
\r
1018 extern const tFont g_sFontCmss46i;
\r
1019 extern const tFont g_sFontCmss48;
\r
1020 extern const tFont g_sFontCmss48b;
\r
1021 extern const tFont g_sFontCmss48i;
\r
1022 extern const tFont g_sFontFixed6x8;
\r
1024 //*****************************************************************************
\r
1026 //! Translates a 24-bit RGB color to a display driver-specific color.
\r
1028 //! \param pDisplay is the pointer to the display driver structure for the
\r
1029 //! display to operate upon.
\r
1030 //! \param ulValue is the 24-bit RGB color. The least-significant byte is the
\r
1031 //! blue channel, the next byte is the green channel, and the third byte is the
\r
1034 //! This function translates a 24-bit RGB color into a value that can be
\r
1035 //! written into the display's frame buffer in order to reproduce that color,
\r
1036 //! or the closest possible approximation of that color.
\r
1038 //! \return Returns the display-driver specific color.
\r
1040 //*****************************************************************************
\r
1041 #define DpyColorTranslate(pDisplay, ulValue) \
\r
1042 ((pDisplay)->pfnColorTranslate((pDisplay)->pvDisplayData, ulValue))
\r
1044 //*****************************************************************************
\r
1046 //! Flushes cached drawing operations.
\r
1048 //! \param pDisplay is the pointer to the display driver structure for the
\r
1049 //! display to operate upon.
\r
1051 //! This function flushes any cached drawing operations on a display.
\r
1055 //*****************************************************************************
\r
1056 #define DpyFlush(pDisplay) \
\r
1059 const tDisplay *pD = pDisplay; \
\r
1060 pD->pfnFlush(pD->pvDisplayData); \
\r
1064 //*****************************************************************************
\r
1066 //! Gets the height of the display.
\r
1068 //! \param pDisplay is a pointer to the display driver structure for the
\r
1069 //! display to query.
\r
1071 //! This function determines the height of the display.
\r
1073 //! \return Returns the height of the display in pixels.
\r
1075 //*****************************************************************************
\r
1076 #define DpyHeightGet(pDisplay) \
\r
1077 ((pDisplay)->usHeight)
\r
1079 //*****************************************************************************
\r
1081 //! Draws a horizontal line on a display.
\r
1083 //! \param pDisplay is the pointer to the display driver structure for the
\r
1084 //! display to operate upon.
\r
1085 //! \param lX1 is the starting X coordinate of the line.
\r
1086 //! \param lX2 is the ending X coordinate of the line.
\r
1087 //! \param lY is the Y coordinate of the line.
\r
1088 //! \param ulValue is the color to draw the line.
\r
1090 //! This function draws a horizontal line on a display. This assumes that
\r
1091 //! clipping has already been performed, and that both end points of the line
\r
1092 //! are within the extents of the display.
\r
1096 //*****************************************************************************
\r
1097 #define DpyLineDrawH(pDisplay, lX1, lX2, lY, ulValue) \
\r
1100 const tDisplay *pD = pDisplay; \
\r
1101 pD->pfnLineDrawH(pD->pvDisplayData, lX1, lX2, lY, ulValue); \
\r
1105 //*****************************************************************************
\r
1107 //! Draws a vertical line on a display.
\r
1109 //! \param pDisplay is the pointer to the display driver structure for the
\r
1110 //! display to operate upon.
\r
1111 //! \param lX is the X coordinate of the line.
\r
1112 //! \param lY1 is the starting Y coordinate of the line.
\r
1113 //! \param lY2 is the ending Y coordinate of the line.
\r
1114 //! \param ulValue is the color to draw the line.
\r
1116 //! This function draws a vertical line on a display. This assumes that
\r
1117 //! clipping has already been performed, and that both end points of the line
\r
1118 //! are within the extents of the display.
\r
1122 //*****************************************************************************
\r
1123 #define DpyLineDrawV(pDisplay, lX, lY1, lY2, ulValue) \
\r
1126 const tDisplay *pD = pDisplay; \
\r
1127 pD->pfnLineDrawV(pD->pvDisplayData, lX, lY1, lY2, ulValue); \
\r
1131 //*****************************************************************************
\r
1133 //! Draws a pixel on a display.
\r
1135 //! \param pDisplay is the pointer to the display driver structure for the
\r
1136 //! display to operate upon.
\r
1137 //! \param lX is the X coordinate of the pixel.
\r
1138 //! \param lY is the Y coordinate of the pixel.
\r
1139 //! \param ulValue is the color to draw the pixel.
\r
1141 //! This function draws a pixel on a display. This assumes that clipping has
\r
1142 //! already been performed.
\r
1146 //*****************************************************************************
\r
1147 #define DpyPixelDraw(pDisplay, lX, lY, ulValue) \
\r
1150 const tDisplay *pD = pDisplay; \
\r
1151 pD->pfnPixelDraw(pD->pvDisplayData, lX, lY, ulValue); \
\r
1155 //*****************************************************************************
\r
1157 //! Draws a horizontal sequence of pixels on a display.
\r
1159 //! \param pDisplay is the pointer to the display driver structure for the
\r
1160 //! display to operate upon.
\r
1161 //! \param lX is the X coordinate of the first pixel.
\r
1162 //! \param lY is the Y coordinate of the first pixel.
\r
1163 //! \param lX0 is sub-pixel offset within the pixel data, which is valid for 1
\r
1164 //! or 4 bit per pixel formats.
\r
1165 //! \param lCount is the number of pixels to draw.
\r
1166 //! \param lBPP is the number of bits per pixel; must be 1, 4, or 8.
\r
1167 //! \param pucData is a pointer to the pixel data. For 1 and 4 bit per pixel
\r
1168 //! formats, the most significant bit(s) represent the left-most pixel.
\r
1169 //! \param pucPalette is a pointer to the palette used to draw the pixels.
\r
1171 //! This function draws a horizontal sequence of pixels on a display, using the
\r
1172 //! supplied palette. For 1 bit per pixel format, the palette contains
\r
1173 //! pre-translated colors; for 4 and 8 bit per pixel formats, the palette
\r
1174 //! contains 24-bit RGB values that must be translated before being written to
\r
1179 //*****************************************************************************
\r
1180 #define DpyPixelDrawMultiple(pDisplay, lX, lY, lX0, lCount, lBPP, pucData, \
\r
1184 const tDisplay *pD = pDisplay; \
\r
1185 pD->pfnPixelDrawMultiple(pD->pvDisplayData, lX, lY, lX0, lCount, \
\r
1186 lBPP, pucData, pucPalette); \
\r
1190 //*****************************************************************************
\r
1192 //! Fills a rectangle on a display.
\r
1194 //! \param pDisplay is the pointer to the display driver structure for the
\r
1195 //! display to operate upon.
\r
1196 //! \param pRect is a pointer to the structure describing the rectangle to
\r
1198 //! \param ulValue is the color to fill the rectangle.
\r
1200 //! This function fills a rectangle on the display. This assumes that clipping
\r
1201 //! has already been performed, and that all sides of the rectangle are within
\r
1202 //! the extents of the display.
\r
1206 //*****************************************************************************
\r
1207 #define DpyRectFill(pDisplay, pRect, ulValue) \
\r
1210 const tDisplay *pD = pDisplay; \
\r
1211 pD->pfnRectFill(pD->pvDisplayData, pRect, ulValue); \
\r
1215 //*****************************************************************************
\r
1217 //! Gets the width of the display.
\r
1219 //! \param pDisplay is a pointer to the display driver structure for the
\r
1220 //! display to query.
\r
1222 //! This function determines the width of the display.
\r
1224 //! \return Returns the width of the display in pixels.
\r
1226 //*****************************************************************************
\r
1227 #define DpyWidthGet(pDisplay) \
\r
1228 ((pDisplay)->usWidth)
\r
1230 //*****************************************************************************
\r
1232 // Prototypes for the graphics library functions.
\r
1234 //*****************************************************************************
\r
1235 extern void GrCircleDraw(const tContext *pContext, long lX, long lY,
\r
1237 extern void GrCircleFill(const tContext *pContext, long lX, long lY,
\r
1239 extern void GrContextClipRegionSet(tContext *pContext, tRectangle *pRect);
\r
1240 extern void GrContextInit(tContext *pContext, const tDisplay *pDisplay);
\r
1241 extern void GrImageDraw(const tContext *pContext,
\r
1242 const unsigned char *pucImage, long lX, long lY);
\r
1243 extern void GrLineDraw(const tContext *pContext, long lX1, long lY1, long lX2,
\r
1245 extern void GrLineDrawH(const tContext *pContext, long lX1, long lX2, long lY);
\r
1246 extern void GrLineDrawV(const tContext *pContext, long lX, long lY1, long lY2);
\r
1247 extern void GrOffScreen1BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
\r
1248 long lWidth, long lHeight);
\r
1249 extern void GrOffScreen4BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
\r
1250 long lWidth, long lHeight);
\r
1251 extern void GrOffScreen4BPPPaletteSet(tDisplay *pDisplay,
\r
1252 unsigned long *pulPalette,
\r
1253 unsigned long ulOffset,
\r
1254 unsigned long ulCount);
\r
1255 extern void GrOffScreen8BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
\r
1256 long lWidth, long lHeight);
\r
1257 extern void GrOffScreen8BPPPaletteSet(tDisplay *pDisplay,
\r
1258 unsigned long *pulPalette,
\r
1259 unsigned long ulOffset,
\r
1260 unsigned long ulCount);
\r
1261 extern void GrRectDraw(const tContext *pContext, const tRectangle *pRect);
\r
1262 extern void GrRectFill(const tContext *pContext, const tRectangle *pRect);
\r
1263 extern void GrStringDraw(const tContext *pContext, const char *pcString,
\r
1264 long lLength, long lX, long lY,
\r
1265 unsigned long bOpaque);
\r
1266 extern long GrStringWidthGet(const tContext *pContext, const char *pcString,
\r
1269 //*****************************************************************************
\r
1271 // Mark the end of the C bindings section for C++ compilers.
\r
1273 //*****************************************************************************
\r
1274 #ifdef __cplusplus
\r
1278 //*****************************************************************************
\r
1280 // Close the Doxygen group.
\r
1283 //*****************************************************************************
\r
1285 #endif // __GRLIB_H__
\r