?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 * Picture
5 *****************************************************************************
6 * FileName: Picture.c
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 #include "Graphics\Graphics.h"
42  
43 #ifdef USE_PICTURE
44  
45 /*********************************************************************
46 * Function: PICTURE *PictCreate(WORD ID, SHORT left, SHORT top, SHORT right,
47 * SHORT bottom, WORD state, char scale, void *pBitmap,
48 * GOL_SCHEME *pScheme)
49 *
50 * Overview: creates the picture control
51 *
52 ********************************************************************/
53 PICTURE *PictCreate
54 (
55 WORD ID,
56 SHORT left,
57 SHORT top,
58 SHORT right,
59 SHORT bottom,
60 WORD state,
61 char scale,
62 void *pBitmap,
63 GOL_SCHEME *pScheme
64 )
65 {
66 PICTURE *pPict = NULL;
67  
68 pPict = (PICTURE *)GFX_malloc(sizeof(PICTURE));
69 if(pPict == NULL)
70 return (pPict);
71  
72 pPict->hdr.ID = ID;
73 pPict->hdr.pNxtObj = NULL;
74 pPict->hdr.type = OBJ_PICTURE;
75 pPict->hdr.left = left;
76 pPict->hdr.top = top;
77 pPict->hdr.right = right;
78 pPict->hdr.bottom = bottom;
79 pPict->pBitmap = pBitmap;
80 pPict->hdr.state = state;
81 pPict->scale = scale;
82  
83 // Set the style scheme to be used
84 if(pScheme == NULL)
85 pPict->hdr.pGolScheme = _pDefaultGolScheme;
86 else
87 pPict->hdr.pGolScheme = (GOL_SCHEME *)pScheme;
88  
89 GOLAddObject((OBJ_HEADER *)pPict);
90  
91 return (pPict);
92 }
93  
94 /*********************************************************************
95 * Function: WORD PictTranslateMsg(PICTURE *pPict, GOL_MSG *pMsg)
96 *
97 * Overview: translates the GOL message for the picture control
98 *
99 ********************************************************************/
100 WORD PictTranslateMsg(PICTURE *pPict, GOL_MSG *pMsg)
101 {
102  
103 // Evaluate if the message is for the picture
104 // Check if disabled first
105 if(GetState(pPict, PICT_DISABLED))
106 return (OBJ_MSG_INVALID);
107  
108 #ifdef USE_TOUCHSCREEN
109 if(pMsg->type == TYPE_TOUCHSCREEN)
110 {
111  
112 // Check if it falls in the picture area
113 if
114 (
115 (pPict->hdr.left < pMsg->param1) &&
116 (pPict->hdr.right > pMsg->param1) &&
117 (pPict->hdr.top < pMsg->param2) &&
118 (pPict->hdr.bottom > pMsg->param2)
119 )
120 {
121 return (PICT_MSG_SELECTED);
122 }
123 }
124  
125 #endif
126 return (OBJ_MSG_INVALID);
127 }
128  
129 /*********************************************************************
130 * Function: WORD PictDraw(PICTURE *pPict)
131 *
132 * Output: returns the status of the drawing
133 * 0 - not completed
134 * 1 - done
135 *
136 * Overview: draws picture
137 *
138 ********************************************************************/
139 WORD PictDraw(PICTURE *pPict)
140 {
141 typedef enum
142 {
143 REMOVE,
144 DRAW_IMAGE,
145 DRAW_BACKGROUND1,
146 DRAW_BACKGROUND2,
147 DRAW_BACKGROUND3,
148 DRAW_BACKGROUND4,
149 DRAW_FRAME
150 } PICT_DRAW_STATES;
151  
152 static PICT_DRAW_STATES state = REMOVE;
153 static SHORT posleft;
154 static SHORT postop;
155 static SHORT posright;
156 static SHORT posbottom;
157  
158 if(IsDeviceBusy())
159 return (0);
160  
161 switch(state)
162 {
163 case REMOVE:
164 if(GetState(pPict, PICT_HIDE))
165 {
166 SetColor(pPict->hdr.pGolScheme->CommonBkColor);
167 if(!Bar(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom))
168 return (0);
169 return (1);
170 }
171  
172 posleft = (pPict->hdr.left + pPict->hdr.right - pPict->scale * GetImageWidth(pPict->pBitmap)) >> 1;
173 postop = (pPict->hdr.top + pPict->hdr.bottom - pPict->scale * GetImageHeight(pPict->pBitmap)) >> 1;
174 posright = (pPict->hdr.right + pPict->hdr.left + pPict->scale * GetImageWidth(pPict->pBitmap)) >> 1;
175 posbottom = (pPict->hdr.bottom + pPict->hdr.top + pPict->scale * GetImageHeight(pPict->pBitmap)) >> 1;
176 state = DRAW_IMAGE;
177  
178 case DRAW_IMAGE:
179 if(pPict->pBitmap != NULL)
180 {
181 if(IsDeviceBusy())
182 return (0);
183 if(!PutImage(posleft, postop, pPict->pBitmap, pPict->scale))
184 return (0);
185 }
186  
187 SetColor(pPict->hdr.pGolScheme->CommonBkColor);
188 state = DRAW_BACKGROUND1;
189  
190 case DRAW_BACKGROUND1:
191 if(!Bar(pPict->hdr.left + 1, pPict->hdr.top + 1, pPict->hdr.right - 1, postop - 1))
192 return (0);
193 state = DRAW_BACKGROUND2;
194  
195 case DRAW_BACKGROUND2:
196 if(!Bar(pPict->hdr.left + 1, posbottom, pPict->hdr.right - 1, pPict->hdr.bottom - 1))
197 return (0);
198 state = DRAW_BACKGROUND3;
199  
200 case DRAW_BACKGROUND3:
201 if(!Bar(pPict->hdr.left + 1, postop, posleft - 1, posbottom))
202 return (0);
203 state = DRAW_BACKGROUND4;
204  
205 case DRAW_BACKGROUND4:
206 if(!Bar(posright, postop, pPict->hdr.right - 1, posbottom))
207 return (0);
208 state = DRAW_FRAME;
209  
210 case DRAW_FRAME:
211 if(GetState(pPict, PICT_FRAME))
212 {
213 SetLineType(SOLID_LINE);
214 SetColor(pPict->hdr.pGolScheme->TextColor0);
215 if(!Rectangle(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom))
216 return (0);
217 }
218  
219 state = REMOVE;
220 return (1);
221 }
222  
223 return (1);
224 }
225  
226 #endif // USE_PICTURE
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3