Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /***************************************************************************** |
2 | * Module for Microchip Graphics Library |
||
3 | * GOL Layer |
||
4 | * Window |
||
5 | ***************************************************************************** |
||
6 | * FileName: Window.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 _WINDOW_H |
||
42 | #define _WINDOW_H |
||
43 | |||
44 | #include <Graphics\GOL.h> |
||
45 | |||
46 | // Indent for the title bar text from the left side of bitmap or title bar emboss |
||
47 | #define WND_INDENT 2 |
||
48 | |||
49 | // Height of the title bar |
||
50 | #define WND_TITLE_HEIGHT 35 |
||
51 | |||
52 | /********************************************************************* |
||
53 | * Object States Definition: |
||
54 | *********************************************************************/ |
||
55 | #define WND_FOCUSED 0x0001 // Bit for focus state |
||
56 | #define WND_DISABLED 0x0002 // Bit for disabled state |
||
57 | #define WND_TITLECENTER 0x0004 // Bit to center the text on the Title Area |
||
58 | #define WND_HIDE 0x8000 // Bit to indicate window must be removed from screen |
||
59 | #define WND_DRAW_CLIENT 0x4000 // Bit to indicate client area must be redrawn |
||
60 | #define WND_DRAW_TITLE 0x2000 // Bit to indicate title area must be redrawn |
||
61 | #define WND_DRAW 0x6000 // Bits to indicate whole window must be redrawn |
||
62 | |||
63 | /***************************************************************************** |
||
64 | * Overview: The structure contains data for the window |
||
65 | *****************************************************************************/ |
||
66 | typedef struct |
||
67 | { |
||
68 | OBJ_HEADER hdr; // Generic header for all Objects (see OBJ_HEADER). |
||
69 | SHORT textHeight; // Pre-computed text height |
||
70 | XCHAR *pText; // Pointer to the title text |
||
71 | void *pBitmap; // Pointer to the bitmap for the title bar |
||
72 | } WINDOW; |
||
73 | |||
74 | /********************************************************************* |
||
75 | * Function: WINDOW *WndCreate(WORD ID, SHORT left, SHORT top, SHORT right, |
||
76 | * SHORT bottom, WORD state, void* pBitmap, XCHAR* pText, |
||
77 | * GOL_SCHEME *pScheme) |
||
78 | * |
||
79 | * Overview: This function creates a WINDOW object with the parameters |
||
80 | * given. It automatically attaches the new object into a |
||
81 | * global linked list of objects and returns the address |
||
82 | * of the object. |
||
83 | * |
||
84 | * PreCondition: none |
||
85 | * |
||
86 | * Input: ID - Unique user defined ID for the object instance. |
||
87 | * left - Left most position of the Object. |
||
88 | * top - Top most position of the Object. |
||
89 | * right - Right most position of the Object. |
||
90 | * bottom - Bottom most position of the object. |
||
91 | * state - Sets the initial state of the object. |
||
92 | * pBitmap - Pointer to the bitmap used in the title bar. |
||
93 | * pText - Pointer to the text used as a title of the window. |
||
94 | * pScheme - Pointer to the style scheme used. |
||
95 | * |
||
96 | * Output: Returns the pointer to the object created |
||
97 | * |
||
98 | * Example: |
||
99 | * <CODE> |
||
100 | * WINDOW *pWindow; |
||
101 | * pWindow = WndCreate(ID_WINDOW1, // ID |
||
102 | * 0,0,GetMaxX(),GetMaxY(), // whole screen dimension |
||
103 | * WND_DRAW, // set state to draw all |
||
104 | * (char*)myIcon, // icon |
||
105 | * "Place Title Here.", // text |
||
106 | * NULL); // use default GOL scheme |
||
107 | * |
||
108 | * if (pWindow == NULL) |
||
109 | * return 0; |
||
110 | * WndDraw(pWindow); |
||
111 | * return 1; |
||
112 | * </CODE> |
||
113 | * |
||
114 | * Side Effects: none |
||
115 | * |
||
116 | ********************************************************************/ |
||
117 | WINDOW *WndCreate |
||
118 | ( |
||
119 | WORD ID, |
||
120 | SHORT left, |
||
121 | SHORT top, |
||
122 | SHORT right, |
||
123 | SHORT bottom, |
||
124 | WORD state, |
||
125 | void *pBitmap, |
||
126 | XCHAR *pText, |
||
127 | GOL_SCHEME *pScheme |
||
128 | ); |
||
129 | |||
130 | /********************************************************************* |
||
131 | * Macros: WndGetText(pW) |
||
132 | * |
||
133 | * Overview: This macro returns the address of the current |
||
134 | * text string used for the title bar. |
||
135 | * |
||
136 | * PreCondition: none |
||
137 | * |
||
138 | * Input: pW - Pointer to the object |
||
139 | * |
||
140 | * Output: Returns pointer to the text string being used. |
||
141 | * |
||
142 | * Example: |
||
143 | * <CODE> |
||
144 | * WINDOW *pWindow; |
||
145 | * XCHAR textUsed = USE THIS!; |
||
146 | * |
||
147 | * if (WndGetText(pWindow) == NULL) |
||
148 | * WndSetText(&textUsed); |
||
149 | * </CODE> |
||
150 | * |
||
151 | * Side Effects: none |
||
152 | * |
||
153 | ********************************************************************/ |
||
154 | #define WndGetText(pW) pW->pText |
||
155 | |||
156 | /********************************************************************* |
||
157 | * Function: WndSetText(WINDOW *pW, XCHAR *pText) |
||
158 | * |
||
159 | * Overview: This function sets the string used for the title bar. |
||
160 | * |
||
161 | * PreCondition: none |
||
162 | * |
||
163 | * Input: pW - The pointer to the object whose text will be modified |
||
164 | * pText - Pointer to the text that will be used |
||
165 | * |
||
166 | * Output: none |
||
167 | * |
||
168 | * Example: |
||
169 | * See WndGetText() example. |
||
170 | * |
||
171 | * Side Effects: none |
||
172 | * |
||
173 | ********************************************************************/ |
||
174 | void WndSetText(WINDOW *pW, XCHAR *pText); |
||
175 | |||
176 | /********************************************************************* |
||
177 | * Function: WORD WndTranslateMsg(WINDOW *pW, GOL_MSG *pMsg) |
||
178 | * |
||
179 | * Overview: This function evaluates the message from a user if |
||
180 | * the message will affect the object or not. The table |
||
181 | * below enumerates the translated messages for each |
||
182 | * event of the touch screen inputs. |
||
183 | * |
||
184 | * <TABLE> |
||
185 | * Translated Message Input Source Events Description |
||
186 | * ################## ############ ###### ########### |
||
187 | * WND_MSG_TITLE Touch Screen EVENT_PRESS, EVENT_RELEASE, EVENT_MOVE If events occurs and the x,y position falls in the TITLE area of the window |
||
188 | * WND_MSG_CLIENT Touch Screen EVENT_PRESS, EVENT_RELEASE, EVENT_MOVE If events occurs and the x,y position falls in the CLIENT area of the window |
||
189 | * OBJ_MSG_INVALID Any Any If the message did not affect the object. |
||
190 | * </TABLE> |
||
191 | * |
||
192 | * PreCondition: none |
||
193 | * |
||
194 | * Input: pW - The pointer to the object where the message will be |
||
195 | * evaluated to check if the message will affect the object. |
||
196 | * pMsg - Pointer to the message struct containing the message from |
||
197 | * the user interface. |
||
198 | * |
||
199 | * Output: Returns the translated message depending on the received GOL message: |
||
200 | * - WND_MSG_TITLE Title area is selected |
||
201 | * - WND_MSG_CLIENT Client area is selected |
||
202 | * - OBJ_MSG_INVALID Window is not affected |
||
203 | * |
||
204 | * Example: |
||
205 | * Usage is similar to BtnTranslateMsg() example. |
||
206 | * |
||
207 | * Side Effects: none |
||
208 | * |
||
209 | ********************************************************************/ |
||
210 | WORD WndTranslateMsg(WINDOW *pW, GOL_MSG *pMsg); |
||
211 | |||
212 | /********************************************************************* |
||
213 | * Function: WORD WndDraw(WINDOW *pW) |
||
214 | * |
||
215 | * Overview: This function renders the object on the screen |
||
216 | * using the current parameter settings. Location of |
||
217 | * the object is determined by the left, top, right |
||
218 | * and bottom parameters. The colors used are dependent |
||
219 | * on the state of the object. The font used is |
||
220 | * determined by the style scheme set. |
||
221 | * |
||
222 | * When rendering objects of the same type, each object |
||
223 | * must be rendered completely before the rendering of the |
||
224 | * next object is started. This is to avoid incomplete |
||
225 | * object rendering. |
||
226 | * |
||
227 | * PreCondition: Object must be created before this function is called. |
||
228 | * |
||
229 | * Input: pW - Pointer to the object to be rendered. |
||
230 | * |
||
231 | * Output: Returns the status of the drawing |
||
232 | * - 1 - If the rendering was completed and |
||
233 | * - 0 - If the rendering is not yet finished. |
||
234 | * Next call to the function will resume the |
||
235 | * rendering on the pending drawing state. |
||
236 | * |
||
237 | * Example: |
||
238 | * See WndCreate() example. |
||
239 | * |
||
240 | * Side Effects: none |
||
241 | * |
||
242 | ********************************************************************/ |
||
243 | WORD WndDraw(WINDOW *pW); |
||
244 | #endif // _WINDOW_H |
Powered by WebSVN v2.8.3