?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 * GOL Layer
4 * Radio Button
5 *****************************************************************************
6 * FileName: RadioButton.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 * Anton Alkhimenok 11/12/07 Version 1.0 release
40 *****************************************************************************/
41 #ifndef _RADIOBUTTON_H
42 #define _RADIOBUTTON_H
43  
44 #include <Graphics\GOL.h>
45  
46 #define RB_INDENT 2 // Indent for the text from title bar border
47  
48 /*********************************************************************
49 * Object States Definition:
50 *********************************************************************/
51 #define RB_FOCUSED 0x0001 // Bit for focused state.
52 #define RB_DISABLED 0x0002 // Bit for disabled state.
53 #define RB_CHECKED 0x0004 // Bit to indicate <link Radio Button> is checked.
54 #define RB_GROUP 0x0008 // Bit to indicate the first <link Radio Button> in the group.
55 #define RB_HIDE 0x8000 // Bit to indicate that button must be removed from screen.
56 #define RB_DRAW_FOCUS 0x2000 // Bit to indicate focus must be redrawn.
57 #define RB_DRAW_CHECK 0x1000 // Bit to indicate check mark should be redrawn.
58 #define RB_DRAW 0x4000 // Bit to indicate whole <link Radio Button> must be redrawn.
59  
60 /*****************************************************************************
61 * Overview: the structure contains data for the <link Radio Button>
62 *****************************************************************************/
63 typedef struct
64 {
65 OBJ_HEADER hdr; // Generic header for all Objects (see OBJ_HEADER).
66 OBJ_HEADER *pHead; // Pointer to the first <link Radio Button> in the group
67 OBJ_HEADER *pNext; // Pointer to the next <link Radio Button> in the group
68 SHORT textHeight; // Pre-computed text height
69 XCHAR *pText; // Pointer to the text
70 } RADIOBUTTON;
71  
72 /*********************************************************************
73 * Macros: RbGetText(pRb)
74 *
75 * Overview: This macro returns the address of the current
76 * text string used for the object.
77 *
78 * PreCondition: none
79 *
80 * Input: pRb - Pointer to the object
81 *
82 * Output: Returns pointer to the text string being used.
83 *
84 * Side Effects: none
85 *
86 ********************************************************************/
87 #define RbGetText(pRb) pRb->pText
88  
89 /*********************************************************************
90 * Function: RbSetText(RADIOBUTTON *pRb, XCHAR *pText)
91 *
92 * Overview: This function sets the string used for the object.
93 *
94 * PreCondition: none
95 *
96 * Input: pRb - The pointer to the object whose text will be modified
97 * pText - Pointer to the text that will be used
98 *
99 * Output: none
100 *
101 * Side Effects: none
102 *
103 ********************************************************************/
104 void RbSetText(RADIOBUTTON *pRb, XCHAR *pText);
105  
106 /*********************************************************************
107 * Function: void RbSetCheck(RADIOBUTTON *pRb, WORD ID)
108 *
109 * Overview: This function sets the <link Radio Button> with the given ID
110 * to its checked state.
111 *
112 * PreCondition: none
113 *
114 * Input: pRb - Pointer to the <link Radio Button> in the group.
115 * ID - ID of the object to be checked.
116 *
117 * Output: none
118 *
119 * Example:
120 * See RbGetCheck() example.
121 *
122 * Side Effects: none
123 *
124 ********************************************************************/
125 void RbSetCheck(RADIOBUTTON *pRb, WORD ID);
126  
127 /*********************************************************************
128 * Function: WORD RbGetCheck(RADIOBUTTON *pRb)
129 *
130 * Overview: This function returns the ID of the currently
131 * checked <link Radio Button> in the group.
132 *
133 * PreCondition: none
134 *
135 * Input: pRb - Pointer to the <link Radio Button> in the group.
136 *
137 * Output: Returns the ID of the selected button in the group.
138 * It returns -1 if there is no object checked.
139 *
140 * Example:
141 * <CODE>
142 * GOL_SCHEME *pScheme;
143 * RADIOBUTTON *pRb[3];
144 * SHORT ID;
145 *
146 * pScheme = GOLCreateScheme();
147 * pRb[0] = RbCreate(ID_RADIOBUTTON1, // ID
148 * 255,40,310,80, // dimension
149 * RB_DRAW|RB_GROUP|RB_CHECKED, // will be dislayed and
150 * // focused after creation
151 * // first button in the group
152 * "RB1", // text
153 * pScheme); // scheme used
154 *
155 * pRb[1] = RbCreate(ID_RADIOBUTTON2, // ID
156 * 255,85,310,125, // dimension
157 * RB_DRAW, // will be dislayed and
158 * // checked after creation
159 * "RB2", // text
160 * pScheme); // scheme used
161 *
162 * pRb[2] = RbCreate(ID_RADIOBUTTON3, // ID
163 * 255,130,310,170, // dimension
164 * RB_DRAW, // will be dislayed and
165 * // disabled after creation
166 * "RB3", // text
167 * pScheme); // scheme used
168 *
169 * // draw the Radio Buttons here
170 *
171 * ID = RbGetCheck(pRb[2]); // can also use pRb[1] or
172 * // pRb[0] to search the
173 * // checked radio button of the
174 * // group. ID here should
175 * // be ID_RADIOBUTTON1
176 * if (ID == ID_RADIOBUTTON1) {
177 * // do something here then clear the check
178 * ClrState(pRb[0], RB_CHECKED);
179 * // Change the checked object. Pointer used is any of the three.
180 * // the ID used will find the correct object to be checked
181 * RbSetCheck(pRb[3], ID_RADIOBUTTON2);
182 * }
183 * </CODE>
184 *
185 * Side Effects: none
186 *
187 ********************************************************************/
188 WORD RbGetCheck(RADIOBUTTON *pRb);
189  
190 /*********************************************************************
191 * Function: RADIOBUTTON *RbCreate( WORD ID, SHORT left, SHORT top,
192 * SHORT right, SHORT bottom, WORD state,
193 * XCHAR *pText, GOL_SCHEME *pScheme)
194 *
195 * Overview: This function creates a RADIOBUTTON object with the parameters given.
196 * It automatically attaches the new object into a global linked list of
197 * objects and returns the address of the object.
198 *
199 * PreCondition: none
200 *
201 * Input: ID - Unique user defined ID for the object instance.
202 * left - Left most position of the Object.
203 * top - Top most position of the Object.
204 * right - Right most position of the Object
205 * bottom - Bottom most position of the object
206 * state - Sets the initial state of the object
207 * pText – The pointer to the text used for the <link Radio Button>.
208 * pScheme - Pointer to the style scheme used.
209 *
210 * Output: Returns the pointer to the object created
211 *
212 * Example:
213 * <CODE>
214 * GOL_SCHEME *pScheme;
215 * RADIOBUTTON *pRb[3];
216 *
217 * pScheme = GOLCreateScheme();
218 * pRb[0] = RbCreate(ID_RADIOBUTTON1, // ID
219 * 255,40,310,80, // dimension
220 * RB_DRAW|RB_GROUP|RB_CHECKED, // will be dislayed and
221 * // focused after creation
222 * // first button in the group
223 * "RB1", // text
224 * pScheme); // scheme used
225 *
226 * pRb[1] = RbCreate(ID_RADIOBUTTON2, // ID
227 * 255,85,310,125, // dimension
228 * RB_DRAW, // will be dislayed and
229 * // checked after creation
230 * "RB2", // text
231 * pScheme); // scheme used
232 *
233 * pRb[2] = RbCreate(ID_RADIOBUTTON3, // ID
234 * 255,130,310,170, // dimension
235 * RB_DRAW, // will be dislayed and
236 * // disabled after creation
237 * "RB3", // text
238 * pScheme); // scheme used
239 *
240 * while(!RbDraw(pRb[0])); // draw the objects
241 * while(!RbDraw(pRb[1]));
242 * while(!RbDraw(pRb[2]));
243 * </CODE>
244 *
245 * Side Effects: none
246 *
247 ********************************************************************/
248 RADIOBUTTON *RbCreate
249 (
250 WORD ID,
251 SHORT left,
252 SHORT top,
253 SHORT right,
254 SHORT bottom,
255 WORD state,
256 XCHAR *pText,
257 GOL_SCHEME *pScheme
258 );
259  
260 /*********************************************************************
261 * Function: WORD RbTranslateMsg(RADIOBUTTON *pRb, GOL_MSG *pMsg)
262 *
263 * Overview: This function evaluates the message from a user if
264 * the message will affect the object or not. The table
265 * below enumerates the translated messages for each event
266 * of the touch screen and keyboard inputs.
267 *
268 * <TABLE>
269 * Translated Message Input Source Events Description
270 * ################## ############ ###### ###########
271 * RB_MSG_CHECKED Touch Screen EVENT_PRESS If event occurs and the x,y position falls in the area of the <link Radio Button> while the <link Radio Button> is not checked.
272 * Keyboard EVENT_KEYSCAN If event occurs and parameter1 passed matches the object’s ID and parameter 2 passed matches SCAN_CR_PRESSED or SCAN_SPACE_PRESSED while the <link Radio Button> is not checked.
273 * OBJ_MSG_INVALID Any Any If the message did not affect the object.
274 * </TABLE>
275 *
276 * PreCondition: none
277 *
278 * Input: pRb - The pointer to the object where the message will be
279 * evaluated to check if the message will affect the object.
280 * pMsg - Pointer to the message struct containing the message from
281 * the user interface.
282 *
283 * Output: Returns the translated message depending on the received GOL message:
284 * - RB_MSG_CHECKED – <link Radio Button> is checked
285 * - OBJ_MSG_INVALID – <link Radio Button> is not affected
286 *
287 * Example:
288 * Usage is similar to BtnTranslateMsg() example.
289 *
290 * Side Effects: none
291 *
292 ********************************************************************/
293 WORD RbTranslateMsg(RADIOBUTTON *pRb, GOL_MSG *pMsg);
294  
295 /*********************************************************************
296 * Function: RbMsgDefault(WORD translatedMsg, RADIOBUTTON *pRb, GOL_MSG* pMsg)
297 *
298 * Overview: This function performs the actual state change
299 * based on the translated message given. The following state changes
300 * are supported:
301 * <TABLE>
302 * Translated Message Input Source Set/Clear State Bit Description
303 * ################## ############ ###### ###########
304 * RB_MSG_CHECKED Touch Screen, Set RB_DRAW, Depending on the current value of RB_CHECKED Check Box will be redrawn.
305 * Keyboard Set/Clear RB_CHECKED
306 * </TABLE>
307 *
308 * PreCondition: none
309 *
310 * Input: translatedMsg - The translated message
311 * pRb - The pointer to the object whose state will be modified
312 * pMsg - The pointer to the GOL message
313 *
314 * Output: none
315 *
316 * Example:
317 * See BtnTranslateMsg() example.
318 *
319 * Side Effects: none
320 *
321 ********************************************************************/
322 void RbMsgDefault(WORD translatedMsg, RADIOBUTTON *pRb, GOL_MSG *pMsg);
323  
324 /*********************************************************************
325 * Function: WORD RbDraw(RADIOBUTTON *pRb)
326 *
327 * Overview: This function renders the object on the screen using
328 * the current parameter settings. Location of the object
329 * is determined by the left, top, right and bottom
330 * parameters. The colors used are dependent on the state
331 * of the object. The font used is determined by the style
332 * scheme set.
333 *
334 * When rendering objects of the same type, each object must
335 * be rendered completely before the rendering of the next
336 * object is started. This is to avoid incomplete object
337 * rendering.
338 *
339 * PreCondition: Object must be created before this function is called.
340 *
341 * Input: pB - Pointer to the object to be rendered.
342 *
343 * Output: Returns the status of the drawing
344 * - 1 - If the rendering was completed and
345 * - 0 - If the rendering is not yet finished.
346 * Next call to the function will resume the
347 * rendering on the pending drawing state.
348 *
349 * Example:
350 * See RbCreate() example.
351 *
352 * Side Effects: none
353 *
354 ********************************************************************/
355 WORD RbDraw(RADIOBUTTON *pRb);
356 #endif // _RADIOBUTTON_H
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3