?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*****************************************************************************
2 * Module for Microchip Graphics Library
3 * Grid control
4 *****************************************************************************
5 * FileName: Grid.h
6 * Dependencies: none
7 * Processor: PIC24F, PIC24H, dsPIC, PIC32
8 * Compiler: MPLAB C30 V3.00, 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 * Kim Otten 02/29/08 ...
39 * PAT 04/16/10 Added Grid Item as text.
40 *****************************************************************************/
41 #ifndef _GRID_H_
42 #define _GRID_H_
43  
44 #include <Graphics\GOL.h>
45  
46 //******************************************************************************
47 // Grid Object State Definitions
48 //******************************************************************************
49 #define GRID_FOCUSED 0x0001 // Bit for focused state
50 #define GRID_DISABLED 0x0002 // Bit for disabled state
51 #define GRID_SHOW_LINES 0x0004 // Display grid lines
52 #define GRID_SHOW_FOCUS 0x0008 // Highlight the focused cell.
53 #define GRID_SHOW_BORDER_ONLY 0x0010 // Draw only the outside border of the grid.
54 #define GRID_SHOW_SEPARATORS_ONLY 0x0020 // Draw only the lines between cells (like Tic-tac-toe)
55 #define GRID_DRAW_ITEMS 0x1000 // Bit to indicate that at least one item must be redrawn, but not the entire grid.
56 #define GRID_DRAW_ALL 0x4000 // Bit to indicate whole edit box must be redrawn
57 #define GRID_HIDE 0x8000 // Bit to remove object from screen
58  
59 //******************************************************************************
60 // Grid Item State Definitions
61 //******************************************************************************
62 #define GRIDITEM_SELECTED 0x0001 // The cell is selected.
63 #define GRIDITEM_IS_TEXT 0x0000 // The grid item is a test string.
64 #define GRIDITEM_IS_BITMAP 0x0008 // The grid item is a bitmap.
65 #define GRIDITEM_TEXTRIGHT 0x0010 // Text in the cell is right aligned.
66 #define GRIDITEM_TEXTLEFT 0x0020 // Text in the cell is left aligned.
67 #define GRIDITEM_TEXTBOTTOM 0x0040 // Bit to indicate text is top aligned.
68 #define GRIDITEM_TEXTTOP 0x0080 // Bit to indicate text is bottom aligned.
69 #define GRIDITEM_DRAW 0x0100 // Draw this cell
70  
71  
72 #define GRID_TYPE_MASK (0x0C)
73 #define GRID_SUCCESS 0x0000 // Status of a successful GridSetCell() operation.
74 #define GRID_OUT_OF_BOUNDS 0x0001 // Status of an out of bounds cell GridSetCell() operation.
75  
76 #define GRID_MAX_COLUMNS(rw, cw) ((rw - (GOL_EMBOSS_SIZE * 2) + 1) / (cw + 1))
77 #define GRID_MAX_ROWS(rh, ch) ((rh - (GOL_EMBOSS_SIZE * 2) + 1) / (ch + 1))
78 #define GRID_WIDTH(c, cw) ((GOL_EMBOSS_SIZE * 2) + (c * (cw + 1)) - 1)
79 #define GRID_HEIGHT(r, ch) ((GOL_EMBOSS_SIZE * 2) + (r * (ch + 1)) - 1)
80  
81 /*********************************************************************
82 * Overview: Defines the grid item.
83 *
84 *********************************************************************/
85 typedef struct
86 {
87 void *data; // Indicates if the Grid Item is type GRIDITEM_IS_TEXT or GRIDITEM_IS_BITMAP
88 WORD status; // indicates the status of the Grid Item
89 } GRIDITEM;
90  
91 /*********************************************************************
92 * Overview: Defines the parameters required for a grid Object.
93 * Clipping is not supported in grid object.
94 *
95 *********************************************************************/
96 typedef struct
97 {
98 OBJ_HEADER hdr; // Generic header for all Objects (see OBJ_HEADER).
99 SHORT numColumns; // Number of columns drawn for the Grid.
100 SHORT numRows; // Number of rows drawn for the Grid.
101 SHORT cellHeight; // The height of each cell in pixels.
102 SHORT cellWidth; // The width of each cell in pixels.
103 SHORT focusX; // The x position of the cell to be focused.
104 SHORT focusY; // The y position of the cell to be focused.
105 GRIDITEM *gridObjects; // The pointer to grid items
106 } GRID;
107  
108 /*********************************************************************
109 * Function: GRID *GridCreate(WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom,
110 * WORD state, SHORT numColumns, SHORT numRows,
111 * SHORT cellWidth, SHORT cellHeight, GOL_SCHEME *pScheme)
112 *
113 * Overview: This function creates a GRID object with the parameters
114 * given. It automatically attaches the new object into a global
115 * linked list of objects and returns the address of the object.
116 *
117 * PreCondition: none
118 *
119 * Input: ID - Unique user defined ID for the object instance.
120 * left - Left most position of the Object.
121 * top - Top most position of the Object.
122 * right - Right most position of the Object.
123 * bottom - Bottom most position of the object.
124 * state - Sets the initial state of the object.
125 * numColumns - Sets the number of columns for the grid.
126 * numRows - Sets the number of rows for the grid.
127 * cellWidth - Sets the width of each cell of the grid.
128 * cellHeight - Sets the height of each cell of the grid.
129 * pScheme - Pointer to the style scheme used for the object.
130 * Set to NULL if default style scheme is used.
131 *
132 * Output: Returns the pointer to the object created.
133 *
134 * Side Effects: none
135 *
136 ********************************************************************/
137 GRID *GridCreate
138 (
139 WORD ID,
140 SHORT left,
141 SHORT top,
142 SHORT right,
143 SHORT bottom,
144 WORD state,
145 SHORT numColumns,
146 SHORT numRows,
147 SHORT cellWidth,
148 SHORT cellHeight,
149 GOL_SCHEME *pScheme
150 );
151  
152 /*********************************************************************
153 * Function: GridClearCellState(GRID *pGrid, SHORT column, SHORT row, WORD state)
154 *
155 * Overview: This function clears the state of the cell (or Grid Item) specified
156 * by the column and row.
157 *
158 * PreCondition: none
159 *
160 * Input: pGrid - Pointer to the object.
161 * column - column index of the cell
162 * row - row index of the cell
163 * atate - specifies the state to be cleared. See Grid Item State.
164 *
165 * Output: none.
166 *
167 * Side Effects: none
168 *
169 ********************************************************************/
170 void GridClearCellState(GRID *pGrid, SHORT column, SHORT row, WORD state);
171  
172  
173 /*********************************************************************
174 * Function: WORD GridDraw(GRID *pGrid)
175 *
176 * Overview: This function renders the object on the screen using
177 * the current parameter settings. Location of the object
178 * is determined by the left, top, right and bottom parameters.
179 * The colors used are dependent on the state of the object.
180 * The font used is determined by the style scheme set.
181 *
182 * When rendering objects of the same type, each object must
183 * be rendered completely before the rendering of the next object
184 * is started. This is to avoid incomplete object rendering.
185 *
186 * PreCondition: Object must be created before this function is called.
187 *
188 * Input: pGb - Pointer to the object to be rendered.
189 *
190 * Output: Returns the status of the drawing
191 * - 1 - If the rendering was completed and
192 * - 0 - If the rendering is not yet finished.
193 * Next call to the function will resume the
194 * rendering on the pending drawing state.
195 *
196 * Side Effects: none
197 *
198 ********************************************************************/
199 WORD GridDraw(GRID *pGrid);
200  
201 /*********************************************************************
202 * Function: GridFreeItems(GRID *pGrid)
203 *
204 * Overview: This function removes all grid items for the given Grid
205 * and frees the memory used.
206 *
207 * PreCondition: Object must be created before this function is called.
208 *
209 * Input: pGrid - The pointer to the Grid object.
210 *
211 * Output: none.
212 *
213 * Side Effects: none
214 *
215 ********************************************************************/
216 void GridFreeItems(GRID *pGrid);
217  
218 /*********************************************************************
219 * Function: *GridGetCell(GRID *pGrid, SHORT column, SHORT row, WORD *cellType)
220 *
221 * Overview: This function removes all grid items for the given Grid
222 * and frees the memory used.
223 *
224 * PreCondition: Object must be created before this function is called.
225 *
226 * Input: pGrid - The pointer to the Grid object.
227 * column - the column index of the cell
228 * row - the row index of the cell
229 * cellType - pointer that will receive the type of grid item
230 * or cell (GRIDITEM_IS_TEXT or GRIDITEM_IS_BITMAP).
231 *
232 * Output: Returns a pointer to the grid item or cell data.
233 *
234 * Side Effects: none
235 *
236 ********************************************************************/
237 void *GridGetCell(GRID *pGrid, SHORT column, SHORT row, WORD *cellType);
238  
239 /*********************************************************************
240 * Macros: GridGetFocusX(pGrid)
241 *
242 * Overview: This macro returns the x position of the focused cell.
243 *
244 * PreCondition: none
245 *
246 * Input: pGrid - Pointer to the object.
247 *
248 * Output: Returns the x position of the focused cell.
249 *
250 * Side Effects: none
251 *
252 ********************************************************************/
253 #define GridGetFocusX(pGrid) pGrid->focusX
254  
255 /*********************************************************************
256 * Macros: GridGetFocusY(pGrid)
257 *
258 * Overview: This macro returns the y position of the focused cell.
259 *
260 * PreCondition: none
261 *
262 * Input: pGrid - Pointer to the object.
263 *
264 * Output: Returns the y position of the focused cell.
265 *
266 * Side Effects: none
267 *
268 ********************************************************************/
269 #define GridGetFocusY(pGrid) pGrid->focusY
270  
271 /*********************************************************************
272 * Function: GridMsgDefault(WORD translatedMsg, GRID *pGrid, GOL_MSG *pMsg)
273 *
274 * Overview: This function performs the actual state change
275 * based on the translated message given. The following state changes
276 * are supported:
277 * <TABLE>
278 * Translated Message Input Source Set/Clear State Bit Description
279 * ################## ############ ###### ###########
280 * GRID_MSG_TOUCHED Touch Screen none Grid will have no state change because of this event.
281 * GRID_MSG_ITEM_SELECTED Keyboard Set GRIDITEM_SELECTED, Grid Item selected will be redrawn.
282 * GRID_DRAW_ITEMS
283 * GRID_MSG_UP Keyboard Set GRIDITEM_DRAW, Grid Item above the currently focused item will be redrawn.
284 * GRID_DRAW_ITEMS
285 * GRID_MSG_DOWN Keyboard Set GRIDITEM_DRAW, Grid Item below the currently focused item will be redrawn.
286 * GRID_DRAW_ITEMS
287 * GRID_MSG_LEFT Keyboard Set GRIDITEM_DRAW, Grid Item to the left of the currently focused item will be redrawn.
288 * GRID_DRAW_ITEMS
289 * GRID_MSG_RIGHT Keyboard Set GRIDITEM_DRAW, Grid Item to the right of the currently focused item will be redrawn.
290 * GRID_DRAW_ITEMS
291 * </TABLE>
292 *
293 * PreCondition: none
294 *
295 * Input: translatedMsg - The translated message.
296 * pGrid - The pointer to the object whose state will be modified.
297 * pMsg - The pointer to the GOL message.
298 *
299 * Output: none
300 *
301 * Side Effects: none
302 *
303 ********************************************************************/
304 void GridMsgDefault(WORD translatedMsg, GRID *pGrid, GOL_MSG *pMsg);
305  
306 /*********************************************************************
307 * Function: GridTranslateMsg(GRID *pGrid, GOL_MSG *pMsg)
308 *
309 * Overview: This function evaluates the message from a user if the
310 * message will affect the object or not. The table below enumerates the translated
311 * messages for each event of the touch screen and keyboard inputs.
312 *
313 * <TABLE>
314 * Translated Message Input Source Set/Clear State Bit Description
315 * ################## ############ ####################### ##################################################################################################################################################################
316 * GRID_MSG_TOUCHED Touch Screen none If any touch events occurs and the x,y position falls in the face of the grid.
317 * GRID_MSG_ITEM_SELECTED Keyboard EVENT_KEYSCAN If event occurs and parameter1 passed matches the object’s ID and parameter 2 passed matches SCAN_SPACE_PRESSED or SCAN_CR_PRESSED.
318 * GRID_MSG_UP Keyboard EVENT_KEYSCAN If event occurs and parameter1 passed matches the object’s ID and parameter 2 passed matches SCAN_UP_PRESSED.
319 * GRID_MSG_DOWN Keyboard EVENT_KEYSCAN If event occurs and parameter1 passed matches the object’s ID and parameter 2 passed matches SCAN_DOWN_PRESSED.
320 * GRID_MSG_LEFT Keyboard EVENT_KEYSCAN If event occurs and parameter1 passed matches the object’s ID and parameter 2 passed matches SCAN_LEFT_PRESSED.
321 * GRID_MSG_RIGHT Keyboard EVENT_KEYSCAN If event occurs and parameter1 passed matches the object’s ID and parameter 2 passed matches SCAN_RIGHT_PRESSED.
322 * OBJ_MSG_INVALID Any Any If the message did not affect the object.
323 * </TABLE>
324 *
325 * PreCondition: none
326 *
327 * Input: pGrid - The pointer to the object where the message will be
328 * evaluated to check if the message will affect the object.
329 * pMsg - Pointer to the message struct containing the message from
330 * the user interface.
331 *
332 * Output: Returns the translated message depending on the received GOL message:
333 * - GRID_MSG_TOUCHED - when the grid object is touched.
334 * - GRID_MSG_ITEM_SELECTED – when key scan SCAN_SPACE_PRESSED or SCAN_CR_PRESSED are detected.
335 * - GRID_MSG_UP – when key scan SCAN_UP_PRESSED is detected.
336 * - GRID_MSG_DOWN – when key scan SCAN_DOWN_PRESSED is detected.
337 * - GRID_MSG_LEFT – when key scan SCAN_LEFT_PRESSED is detected.
338 * - GRID_MSG_RIGHT – when key scan SCAN_RIGHT_PRESSED is detected.
339 * - OBJ_MSG_INVALID – Button is not affected
340 *
341 *
342 * Side Effects: none
343 *
344 ********************************************************************/
345 WORD GridTranslateMsg(GRID *pCb, GOL_MSG *pMsg);
346  
347 /*********************************************************************
348 * Function: WORD GridSetCell(GRID *pGrid, SHORT column, SHORT row, WORD state, void *data)
349 *
350 * Overview: This function sets the Grid Item state and data.
351 *
352 * PreCondition: Object must be created before this function is called.
353 *
354 * Input: pGrid - The pointer to the Grid object.
355 * column - the column index of the cell
356 * row - the row index of the cell
357 * state - sets the state of the Grid Item specified.
358 * data - pointer to the data used for the Grid Item.
359 *
360 * Output: Returns the status of the operation
361 * - GRID_SUCCESS - if the set succeeded
362 * - GRID_OUT_OF_BOUNDS - if the row and column given results in an out of bounds location.
363 *
364 * Side Effects: none
365 *
366 ********************************************************************/
367 WORD GridSetCell(GRID *pGrid, SHORT column, SHORT row, WORD state, void *data);
368  
369 /*********************************************************************
370 * Function: GridSetCellState(GRID *pGrid, SHORT column, SHORT row, WORD state)
371 *
372 * Overview: This function sets the state of the Grid Item or cell.
373 *
374 * PreCondition: Object must be created before this function is called.
375 *
376 * Input: pGrid - The pointer to the Grid object.
377 * column - the column index of the cell
378 * row - the row index of the cell
379 * state - sets the state of the Grid Item specified.
380 *
381 * Output: none.
382 *
383 * Side Effects: none
384 *
385 ********************************************************************/
386 void GridSetCellState(GRID *pGrid, SHORT column, SHORT row, WORD state);
387  
388 /*********************************************************************
389 * Function: GridSetFocus(GRID *pGrid, SHORT column, SHORT row)
390 *
391 * Overview: This function sets the focus of the specified Grid Item or cell.
392 *
393 * PreCondition: Object must be created before this function is called.
394 *
395 * Input: pGrid - The pointer to the Grid object.
396 * column - the column index of the cell
397 * row - the row index of the cell
398 *
399 * Output: none.
400 *
401 * Side Effects: none
402 *
403 ********************************************************************/
404 void GridSetFocus(GRID *pGrid, SHORT column, SHORT row);
405  
406 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3