| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /***************************************************************************** |
| 2 | * Module for Microchip Graphics Library |
||
| 3 | * GOL Layer |
||
| 4 | * Group Box |
||
| 5 | ***************************************************************************** |
||
| 6 | * FileName: GroupBox.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 _GROUPBOX_H |
||
| 42 | #define _GROUPBOX_H |
||
| 43 | |||
| 44 | #include <Graphics\GOL.h> |
||
| 45 | |||
| 46 | /********************************************************************* |
||
| 47 | * Object States Definition: |
||
| 48 | *********************************************************************/ |
||
| 49 | #define GB_DISABLED 0x0002 // Bit for disabled state |
||
| 50 | #define GB_RIGHT_ALIGN 0x0004 // Bit to indicate text is right aligned |
||
| 51 | #define GB_CENTER_ALIGN 0x0008 // Bit to indicate text is center aligned |
||
| 52 | |||
| 53 | // When center and right bits are zero alignment is left |
||
| 54 | #define GB_DRAW 0x4000 // Bit to indicate group box must be redrawn |
||
| 55 | #define GB_HIDE 0x8000 // Bit to remove object from screen |
||
| 56 | |||
| 57 | /********************************************************************* |
||
| 58 | * Overview: Defines the parameters required for a group box Object. |
||
| 59 | * The textwidth and textHeight is not checked with the actual |
||
| 60 | * dimension of the object. Clipping is not supported in |
||
| 61 | * group box object. It is possible for the text to exceed |
||
| 62 | * the dimension of the Object. |
||
| 63 | * |
||
| 64 | *********************************************************************/ |
||
| 65 | typedef struct |
||
| 66 | { |
||
| 67 | OBJ_HEADER hdr; // Generic header for all Objects (see OBJ_HEADER). |
||
| 68 | SHORT textWidth; // Pre-computed text width. |
||
| 69 | SHORT textHeight; // Pre-computed text height. |
||
| 70 | XCHAR *pText; // Text string used. |
||
| 71 | } GROUPBOX; |
||
| 72 | |||
| 73 | /********************************************************************* |
||
| 74 | * Macros: GbGetText(pGb) |
||
| 75 | * |
||
| 76 | * Overview: This macro returns the location of the text used. |
||
| 77 | * |
||
| 78 | * PreCondition: none |
||
| 79 | * |
||
| 80 | * Input: pGb - Pointer to the object. |
||
| 81 | * |
||
| 82 | * Output: Returns the address of the text string used. |
||
| 83 | * |
||
| 84 | * Side Effects: none |
||
| 85 | * |
||
| 86 | ********************************************************************/ |
||
| 87 | #define GbGetText(pB) pGb->pText |
||
| 88 | |||
| 89 | /********************************************************************* |
||
| 90 | * Function: GbSetText(GROUPBOX *pGb, XCHAR *pText) |
||
| 91 | * |
||
| 92 | * Overview: This function sets the text used by passing the pointer |
||
| 93 | * to the static string. |
||
| 94 | * |
||
| 95 | * PreCondition: none |
||
| 96 | * |
||
| 97 | * Input: pGb - the pointer to the object whose state will be modified. |
||
| 98 | * pText - pointer to the text that will be used. |
||
| 99 | * |
||
| 100 | * Output: none |
||
| 101 | * |
||
| 102 | * Side Effects: none |
||
| 103 | * |
||
| 104 | ********************************************************************/ |
||
| 105 | void GbSetText(GROUPBOX *pGb, XCHAR *pText); |
||
| 106 | |||
| 107 | /********************************************************************* |
||
| 108 | * Function: WORD GbTranslateMsg(GROUPBOX *pGb, GOL_MSG *pMsg) |
||
| 109 | * |
||
| 110 | * Overview: This function evaluates the message from a user if the |
||
| 111 | * message will affect the object or not. The table below |
||
| 112 | * enumerates the translated messages for each event of |
||
| 113 | * the touch screen inputs. |
||
| 114 | * |
||
| 115 | * <TABLE> |
||
| 116 | * Translated Message Input Source Events Description |
||
| 117 | * ################## ############ ###### ########### |
||
| 118 | * GB_MSG_SELECTED Touch Screen EVENT_PRESS, EVENT_RELEASE If events occurs and the x,y position falls in the area of the group box. |
||
| 119 | * OBJ_MSG_INVALID Any Any If the message did not affect the object. |
||
| 120 | * </TABLE> |
||
| 121 | * |
||
| 122 | * PreCondition: none |
||
| 123 | * |
||
| 124 | * Input: pGb - The pointer to the object where the message will be |
||
| 125 | * evaluated to check if the message will affect the object. |
||
| 126 | * pMsg - Pointer to the message struct containing the message from |
||
| 127 | * the user interface. |
||
| 128 | * |
||
| 129 | * Output: Returns the translated message depending on the received GOL message: |
||
| 130 | * - GB_MSG_SELECTED Group Box is selected |
||
| 131 | * - OBJ_MSG_INVALID Group Box is not affected |
||
| 132 | * |
||
| 133 | * Example: |
||
| 134 | * Usage is similar to BtnTranslateMsg() example. |
||
| 135 | * |
||
| 136 | * Side Effects: none |
||
| 137 | * |
||
| 138 | ********************************************************************/ |
||
| 139 | WORD GbTranslateMsg(GROUPBOX *pGb, GOL_MSG *pMsg); |
||
| 140 | |||
| 141 | /********************************************************************* |
||
| 142 | * Function: GROUPBOX *GbCreate(WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, |
||
| 143 | * WORD state, XCHAR *pText, GOL_SCHEME *pScheme) |
||
| 144 | * |
||
| 145 | * Overview: This function creates a GROUPBOX object with the parameters |
||
| 146 | * given. It automatically attaches the new object into a global |
||
| 147 | * linked list of objects and returns the address of the object. |
||
| 148 | * |
||
| 149 | * PreCondition: none |
||
| 150 | * |
||
| 151 | * Input: ID - Unique user defined ID for the object instance. |
||
| 152 | * left - Left most position of the Object. |
||
| 153 | * top - Top most position of the Object. |
||
| 154 | * right - Right most position of the Object. |
||
| 155 | * bottom - Bottom most position of the object. |
||
| 156 | * state - Sets the initial state of the object. |
||
| 157 | * pText - The pointer to the text used for the group box. |
||
| 158 | * Length of string must be checked not to exceed the |
||
| 159 | * objects width. Clipping is not supported for the |
||
| 160 | * text of this object. |
||
| 161 | * pScheme - Pointer to the style scheme used for the object. |
||
| 162 | * Set to NULL if default style scheme is used. |
||
| 163 | * |
||
| 164 | * Output: Returns the pointer to the object created. |
||
| 165 | * |
||
| 166 | * Example: |
||
| 167 | * <CODE> |
||
| 168 | * GOL_SCHEME *pScheme; |
||
| 169 | * GROUPBOX *groupbox[2]; |
||
| 170 | * WORD state; |
||
| 171 | * |
||
| 172 | * pScheme = GOLCreateScheme(); |
||
| 173 | * state = GB_DRAW | GB_RIGHT_ALIGN; |
||
| 174 | * groupbox[0] = GbCreate( 10, 14,48,152,122, |
||
| 175 | * state, "Power", scheme); |
||
| 176 | * if (groupbox[0] == NULL) |
||
| 177 | * return 0; |
||
| 178 | * state = GB_DRAW; |
||
| 179 | * groupbox[1] = GbCreate( 11, 160,48,298,122, |
||
| 180 | * state, "Pressure", scheme); |
||
| 181 | * if (groupbox[1] == NULL) |
||
| 182 | * return 0; |
||
| 183 | * |
||
| 184 | * while(!GbDraw(groupbox[0])); |
||
| 185 | * while(!GbDraw(groupbox[1])); |
||
| 186 | * return 1; |
||
| 187 | * </CODE> |
||
| 188 | * |
||
| 189 | * Side Effects: none |
||
| 190 | * |
||
| 191 | ********************************************************************/ |
||
| 192 | GROUPBOX *GbCreate |
||
| 193 | ( |
||
| 194 | WORD ID, |
||
| 195 | SHORT left, |
||
| 196 | SHORT top, |
||
| 197 | SHORT right, |
||
| 198 | SHORT bottom, |
||
| 199 | WORD state, |
||
| 200 | XCHAR *pText, |
||
| 201 | GOL_SCHEME *pScheme |
||
| 202 | ); |
||
| 203 | |||
| 204 | /********************************************************************* |
||
| 205 | * Function: WORD GbDraw(GROUPBOX *pGb); |
||
| 206 | * |
||
| 207 | * Overview: This function renders the object on the screen using |
||
| 208 | * the current parameter settings. Location of the object |
||
| 209 | * is determined by the left, top, right and bottom parameters. |
||
| 210 | * The colors used are dependent on the state of the object. |
||
| 211 | * The font used is determined by the style scheme set. |
||
| 212 | * |
||
| 213 | * When rendering objects of the same type, each object must |
||
| 214 | * be rendered completely before the rendering of the next object |
||
| 215 | * is started. This is to avoid incomplete object rendering. |
||
| 216 | * |
||
| 217 | * PreCondition: Object must be created before this function is called. |
||
| 218 | * |
||
| 219 | * Input: pGb - Pointer to the object to be rendered. |
||
| 220 | * |
||
| 221 | * Output: Returns the status of the drawing |
||
| 222 | * - 1 - If the rendering was completed and |
||
| 223 | * - 0 - If the rendering is not yet finished. |
||
| 224 | * Next call to the function will resume the |
||
| 225 | * rendering on the pending drawing state. |
||
| 226 | * |
||
| 227 | * Example: |
||
| 228 | * See GbCreate() example. |
||
| 229 | * |
||
| 230 | * Side Effects: none |
||
| 231 | * |
||
| 232 | ********************************************************************/ |
||
| 233 | WORD GbDraw(GROUPBOX *pGb); |
||
| 234 | #endif //_GROUPBOX_H |
Powered by WebSVN v2.8.3