| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /***************************************************************************** |
| 2 | * Module for Microchip Graphics Library |
||
| 3 | * GOL Layer |
||
| 4 | * Static text |
||
| 5 | ***************************************************************************** |
||
| 6 | * FileName: StaticText.h |
||
| 7 | * Dependencies: None |
||
| 8 | * Processor: PIC24F, PIC24H, dsPIC, PIC32 |
||
| 9 | * Compiler: MPLAB C30 V3.00, MPLAB C32 |
||
| 10 | * Linker: MPLAB LINK30, MPLAB LINK32 |
||
| 11 | * Company: Microchip Technology Incorporated |
||
| 12 | * |
||
| 13 | * Software License Agreement |
||
| 14 | * |
||
| 15 | * Copyright © 2008 Microchip Technology Inc. All rights reserved. |
||
| 16 | * Microchip licenses to you the right to use, modify, copy and distribute |
||
| 17 | * Software only when embedded on a Microchip microcontroller or digital |
||
| 18 | * signal controller, which is integrated into your product or third party |
||
| 19 | * product (pursuant to the sublicense terms in the accompanying license |
||
| 20 | * agreement). |
||
| 21 | * |
||
| 22 | * You should refer to the license agreement accompanying this Software |
||
| 23 | * for additional information regarding your rights and obligations. |
||
| 24 | * |
||
| 25 | * SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY |
||
| 26 | * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
| 27 | * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR |
||
| 28 | * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR |
||
| 29 | * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, |
||
| 30 | * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT |
||
| 31 | * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, |
||
| 32 | * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, |
||
| 33 | * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY |
||
| 34 | * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), |
||
| 35 | * OR OTHER SIMILAR COSTS. |
||
| 36 | * |
||
| 37 | * Author Date Comment |
||
| 38 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 39 | * Paolo A. Tamayo 11/12/07 Version 1.0 release |
||
| 40 | *****************************************************************************/ |
||
| 41 | #ifndef _STATICTEXT_H |
||
| 42 | #define _STATICTEXT_H |
||
| 43 | |||
| 44 | #include <Graphics\GOL.h> |
||
| 45 | |||
| 46 | /********************************************************************* |
||
| 47 | * Object States Definition: |
||
| 48 | *********************************************************************/ |
||
| 49 | #define ST_DISABLED 0x0002 // Bit for disabled state. |
||
| 50 | #define ST_RIGHT_ALIGN 0x0004 // Bit to indicate text is left aligned. |
||
| 51 | #define ST_CENTER_ALIGN 0x0008 // Bit to indicate text is center aligned. |
||
| 52 | #define ST_FRAME 0x0010 // Bit to indicate frame is displayed. |
||
| 53 | #define ST_UPDATE 0x2000 // Bit to indicate that text area only is redrawn. |
||
| 54 | #define ST_DRAW 0x4000 // Bit to indicate static text must be redrawn. |
||
| 55 | #define ST_HIDE 0x8000 // Bit to remove object from screen. |
||
| 56 | |||
| 57 | /* Indent constant for the text used in the frame. */ |
||
| 58 | #define ST_INDENT 0x02 // Text indent constant. |
||
| 59 | |||
| 60 | /********************************************************************* |
||
| 61 | * Overview: Defines the parameters required for a Static Text Object. |
||
| 62 | * |
||
| 63 | *********************************************************************/ |
||
| 64 | typedef struct |
||
| 65 | { |
||
| 66 | OBJ_HEADER hdr; // Generic header for all Objects (see OBJ_HEADER). |
||
| 67 | SHORT textHeight; // Pre-computed text height. |
||
| 68 | XCHAR *pText; // The pointer to text used. |
||
| 69 | } STATICTEXT; |
||
| 70 | |||
| 71 | /********************************************************************* |
||
| 72 | * Macros: StGetText(pSt) |
||
| 73 | * |
||
| 74 | * Overview: This macro returns the address of the current |
||
| 75 | * text string used for the object. |
||
| 76 | * |
||
| 77 | * PreCondition: none |
||
| 78 | * |
||
| 79 | * Input: pSt - Pointer to the object. |
||
| 80 | * |
||
| 81 | * Output: Returns the pointer to the text string used. |
||
| 82 | * |
||
| 83 | * Side Effects: none |
||
| 84 | * |
||
| 85 | ********************************************************************/ |
||
| 86 | #define StGetText(pSt) pSt->pText |
||
| 87 | |||
| 88 | /********************************************************************* |
||
| 89 | * Function: StSetText(STATICTEXT *pSt, XCHAR *pText) |
||
| 90 | * |
||
| 91 | * Overview: This function sets the string that will be used for the object. |
||
| 92 | * |
||
| 93 | * PreCondition: none |
||
| 94 | * |
||
| 95 | * Input: pSt - The pointer to the object whose text string will be modified. |
||
| 96 | * pText - The pointer to the string that will be used. |
||
| 97 | * |
||
| 98 | * Output: none |
||
| 99 | * |
||
| 100 | * Side Effects: none |
||
| 101 | * |
||
| 102 | ********************************************************************/ |
||
| 103 | void StSetText(STATICTEXT *pSt, XCHAR *pText); |
||
| 104 | |||
| 105 | /********************************************************************* |
||
| 106 | * Function: STATICTEXT *StCreate(WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, |
||
| 107 | * WORD state , XCHAR *pText, GOL_SCHEME *pScheme) |
||
| 108 | * |
||
| 109 | * Overview: This function creates a STATICTEXT object with the |
||
| 110 | * parameters given. It automatically attaches the new |
||
| 111 | * object into a global linked list of objects and returns |
||
| 112 | * the address of the object. |
||
| 113 | * |
||
| 114 | * PreCondition: none |
||
| 115 | * |
||
| 116 | * Input: ID - Unique user defined ID for the object instance. |
||
| 117 | * left - Left most position of the object. |
||
| 118 | * top - Top most position of the object. |
||
| 119 | * right - Right most position of the object. |
||
| 120 | * bottom - Bottom most position of the object. |
||
| 121 | * state - Sets the initial state of the object. |
||
| 122 | * pText - Pointer to the text used in the static text. |
||
| 123 | * pScheme - Pointer to the style scheme. Set to NULL if |
||
| 124 | * default style scheme is used. |
||
| 125 | * |
||
| 126 | * Output: Returns the pointer to the object created. |
||
| 127 | * |
||
| 128 | * Example: |
||
| 129 | * <CODE> |
||
| 130 | * GOL_SCHEME *pScheme; |
||
| 131 | * STATICTEXT *pSt; |
||
| 132 | * |
||
| 133 | * pScheme = GOLCreateScheme(); |
||
| 134 | * state = ST_DRAW | ST_FRAME | ST_CENTER_ALIGN; |
||
| 135 | * StCreate(ID_STATICTEXT1, // ID |
||
| 136 | * 30,80,235,160, // dimension |
||
| 137 | * state, // has frame and center aligned |
||
| 138 | * "Static Text\n Example", // text |
||
| 139 | * pScheme); // use given scheme |
||
| 140 | * |
||
| 141 | * while(!StDraw(pSt)); // draw the object |
||
| 142 | * </CODE> |
||
| 143 | * |
||
| 144 | * Side Effects: none |
||
| 145 | * |
||
| 146 | ********************************************************************/ |
||
| 147 | STATICTEXT *StCreate |
||
| 148 | ( |
||
| 149 | WORD ID, |
||
| 150 | SHORT left, |
||
| 151 | SHORT top, |
||
| 152 | SHORT right, |
||
| 153 | SHORT bottom, |
||
| 154 | WORD state, |
||
| 155 | XCHAR *pText, |
||
| 156 | GOL_SCHEME *pScheme |
||
| 157 | ); |
||
| 158 | |||
| 159 | /********************************************************************* |
||
| 160 | * Function: WORD StTranslateMsg(STATICTEXT *pSt, GOL_MSG *pMsg) |
||
| 161 | * |
||
| 162 | * Overview: This function evaluates the message from a user if the |
||
| 163 | * message will affect the object or not. The table below |
||
| 164 | * enumerates the translated messages for each event of the |
||
| 165 | * touch screen and keyboard inputs. |
||
| 166 | * |
||
| 167 | * <TABLE> |
||
| 168 | * Translated Message Input Source Events Description |
||
| 169 | * ################## ############ ###### ########### |
||
| 170 | * ST_MSG_SELECTED Touch Screen EVENT_PRESS, EVENT_RELEASE If events occurs and the x,y position falls in the area of the static text. |
||
| 171 | * OBJ_MSG_INVALID Any Any If the message did not affect the object. |
||
| 172 | * </TABLE> |
||
| 173 | * |
||
| 174 | * PreCondition: none |
||
| 175 | * |
||
| 176 | * Input: pSt - The pointer to the object where the message will be |
||
| 177 | * evaluated to check if the message will affect the object. |
||
| 178 | * pMsg - Pointer to the message struct containing the message from |
||
| 179 | * the user interface. |
||
| 180 | * |
||
| 181 | * Output: Returns the translated message depending on the received GOL message: |
||
| 182 | * - ST_MSG_SELECTED Static Text is selected |
||
| 183 | * - OBJ_MSG_INVALID Static Text is not affected |
||
| 184 | * |
||
| 185 | * Example: |
||
| 186 | * Usage is similar to BtnTranslateMsg() example. |
||
| 187 | * |
||
| 188 | * Side Effects: none |
||
| 189 | * |
||
| 190 | ********************************************************************/ |
||
| 191 | WORD StTranslateMsg(STATICTEXT *pSt, GOL_MSG *pMsg); |
||
| 192 | |||
| 193 | /********************************************************************* |
||
| 194 | * Function: WORD StDraw(STATICTEXT *pSt) |
||
| 195 | * |
||
| 196 | * Overview: This function renders the object on the screen using |
||
| 197 | * the current parameter settings. Location of the object |
||
| 198 | * is determined by the left, top, right and bottom |
||
| 199 | * parameters. The colors used are dependent on the state |
||
| 200 | * of the object. The font used is determined by the style |
||
| 201 | * scheme set. |
||
| 202 | * |
||
| 203 | * When rendering objects of the same type, each object must |
||
| 204 | * be rendered completely before the rendering of the next |
||
| 205 | * object is started. This is to avoid incomplete object rendering. |
||
| 206 | * |
||
| 207 | * PreCondition: Object must be created before this function is called. |
||
| 208 | * |
||
| 209 | * Input: pSt - Pointer to the object to be rendered. |
||
| 210 | * |
||
| 211 | * Output: Returns the status of the drawing |
||
| 212 | * - 1 - If the rendering was completed and |
||
| 213 | * - 0 - If the rendering is not yet finished. |
||
| 214 | * Next call to the function will resume the |
||
| 215 | * rendering on the pending drawing state. |
||
| 216 | * |
||
| 217 | * Example: |
||
| 218 | * See StCreate() Example. |
||
| 219 | * |
||
| 220 | * Side Effects: none |
||
| 221 | * |
||
| 222 | ********************************************************************/ |
||
| 223 | WORD StDraw(STATICTEXT *pSt); |
||
| 224 | #endif // _STATICTEXT_H |
Powered by WebSVN v2.8.3