eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_scheme.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #include "d4d.h"
48 
49 /**************************************************************
50 *
51 * Global variables
52 *
53 ***************************************************************
54 */
55 
56 D4D_DECLARE_CLR_SCHEME(d4d_clr_scheme_default, \
65  )
66 
67 /*************************************************************
68 *
69 * Local variables
70 *
71 **************************************************************/
72 
73 // pointer to default color scheme pointer
74 static D4D_CLR_SCHEME *pSchemeDefault = (D4D_CLR_SCHEME*)&d4d_clr_scheme_default;
75 
76 
77 /******************************************************************************
78 * Begin of D4D_SCHEME public functions
79 */
83 /**************************************************************************/
91 {
92  if(pScreen == NULL)
93  return pSchemeDefault;
94 
95  if(pScreen->clrScheme != NULL)
96  return pScreen->clrScheme;
97 
98  return pSchemeDefault;
99 }
100 
101 /**************************************************************************/
110 {
111  if(pObj == NULL)
112  return pSchemeDefault;
113 
114  if(pObj->clrScheme != NULL)
115  return pObj->clrScheme;
116 
117  if(pObj->pRelations)
118  {
119  D4D_OBJECT* pParent = D4D_GetParentObject((D4D_OBJECT*)pObj);
120 
121  if(pParent)
122  return D4D_ObjectGetScheme(pParent);
123  }
124 
125  return D4D_ScreenGetScheme(pObj->pData->pScreen);
126 }
127 
128 /**************************************************************************/
134 {
135  return pSchemeDefault;
136 }
137 
138 /**************************************************************************/
146 {
147  if(pScheme == NULL)
148  pSchemeDefault = (D4D_CLR_SCHEME*)&d4d_clr_scheme_default;
149  else
150  pSchemeDefault = pScheme;
151 }
152 
153 /**************************************************************************/
162 {
163  D4D_CLR_SCHEME *pScheme = D4D_ObjectGetScheme(pObj);
164 
165  if(!D4D_IsEnabled(pObj))
166  return pScheme->foreDis;
167 
169  return pScheme->foreCapture;
170 
172  return pScheme->foreFocus;
173 
174  return pScheme->fore;
175 }
176 
177 /**************************************************************************/
186 {
187  D4D_CLR_SCHEME *pScheme = D4D_ObjectGetScheme(pObj);
188 
189  if(!D4D_IsEnabled(pObj))
190  return pScheme->bckgDis;
191 
193  return pScheme->bckgCapture;
194 
196  return pScheme->bckgFocus;
197 
198  return pScheme->bckg;
199 }
200 
201 /**************************************************************************/
209 {
210  D4D_CLR_SCHEME *pScheme = D4D_ObjectGetScheme(pObj);
211 
212  if(!D4D_IsEnabled(pObj))
213  return pScheme->foreDis;
214 
215  return pScheme->fore;
216 }
217 
218 /**************************************************************************/
226 {
227  D4D_CLR_SCHEME *pScheme = D4D_ObjectGetScheme(pObj);
228 
229  if(!D4D_IsEnabled(pObj))
230  return pScheme->bckgDis;
231 
232  return pScheme->bckg;
233 }
234 
235 /**************************************************************************/
243 D4D_COLOR D4D_GetCrossColor(D4D_COLOR startColor, D4D_COLOR endColor, Byte value)
244 {
245  Byte r, g, b;
246  Byte c_s, c_e;
247 
248  //Red color computing
249  c_s = D4D_COLOR_GET_R(startColor);
250  c_e = D4D_COLOR_GET_R(endColor);
251 
252  if(c_s < c_e)
253  r = (Byte)(c_s + D4D_MulDivUU8(value, (Byte)(c_e - c_s), 255));
254  else
255  r = (Byte)(c_s - D4D_MulDivUU8(value, (Byte)(c_s - c_e), 255));
256 
257  //Green color computing
258  c_s = D4D_COLOR_GET_G(startColor);
259  c_e = D4D_COLOR_GET_G(endColor);
260 
261  if(c_s < c_e)
262  g = (Byte)(c_s + D4D_MulDivUU8(value, (Byte)(c_e - c_s), 255));
263  else
264  g = (Byte)(c_s - D4D_MulDivUU8(value, (Byte)(c_s - c_e), 255));
265 
266  //Blue color computing
267  c_s = D4D_COLOR_GET_B(startColor);
268  c_e = D4D_COLOR_GET_B(endColor);
269 
270  if(c_s < c_e)
271  b = (Byte)(c_s + D4D_MulDivUU8(value, (Byte)(c_e - c_s), 255));
272  else
273  b = (Byte)(c_s - D4D_MulDivUU8(value, (Byte)(c_s - c_e), 255));
274 
275  return D4D_COLOR_RGB(r, g, b);
276 
277 }
278 
279 /**************************************************************************/
287 {
288  sWord r, g, b;
289  Byte absIntesity;
290 
291  if(intensity > 100)
292  intensity = 100;
293 
294  if(intensity < -100)
295  intensity = -100;
296 
297  absIntesity = D4D_Abs(intensity);
298 
299 
300  r = D4D_MulDivUU8(absIntesity, D4D_COLOR_GET_R(color), 100);
301  g = D4D_MulDivUU8(absIntesity, D4D_COLOR_GET_G(color), 100);
302  b = D4D_MulDivUU8(absIntesity, D4D_COLOR_GET_B(color), 100);
303 
304  if(intensity > 0)
305  {
306  r += D4D_COLOR_GET_R(color);
307  if(r > 255)
308  r = 255;
309 
310  g += D4D_COLOR_GET_G(color);
311  if(g > 255)
312  g = 255;
313 
314  b += D4D_COLOR_GET_B(color);
315  if(b > 255)
316  b = 255;
317  }else
318  {
319  r = (Byte)(D4D_COLOR_GET_R(color) - r);
320  g = (Byte)(D4D_COLOR_GET_G(color) - g);
321  b = (Byte)(D4D_COLOR_GET_B(color) - b);
322  }
323 
324  return D4D_COLOR_RGB(r, g, b);
325 }
326 
327 /**************************************************************************/
334 {
335  Byte red, green, blue;
336 
337  // Get the separate color components
338  red = D4D_COLOR_GET_R(color);
339  green = D4D_COLOR_GET_G(color);
340  blue = D4D_COLOR_GET_B(color);
341 
342  // Get the arithmetic mean of all color components and store it back as individual components
343  red = green = blue = (Byte)((Word)(red + green + blue) / 3);
344 
345  // Create the color in GreyScale
346  return D4D_COLOR_RGB(red, green, blue);
347 }
348 
349 /******************************************************************************
350 * End of public functions */
352 /******************************************************************************/
D4D_COLOR D4D_GetCrossColor(D4D_COLOR startColor, D4D_COLOR endColor, Byte value)
Compute cross color between two basic color in 256 steps.
Definition: d4d_scheme.c:243
D4D_COLOR D4D_ObjectGetBckgColor(D4D_OBJECT *pObj, D4D_OBJECT_DRAWFLAGS draw)
Function return object current background color.
Definition: d4d_scheme.c:185
D4D_COLOR foreDis
The object fore color in disabled state.
Definition: d4d_scheme.h:586
D4D_OBJECT * D4D_GetParentObject(D4D_OBJECT *pObject)
Definition: d4d_object.c:498
D4D_COLOR D4D_ObjectGetBckgFillColor(D4D_OBJECT *pObj)
Function return object current fill background color.
Definition: d4d_scheme.c:225
D4D_COLOR D4D_ObjectGetForeColor(D4D_OBJECT *pObj, D4D_OBJECT_DRAWFLAGS draw)
Function return object current fore color.
Definition: d4d_scheme.c:161
#define D4D_OBJECT_DRAWFLAGS_FOCUSED
Draw fosused state flag.
Definition: d4d_base.h:362
#define D4D_COLOR_SCR_EXIT_BTN_BCKG
This is screen exit button background color. If not defined, it sets to D4D_COLOR_BRIGHT_RED as a def...
Definition: d4d_scheme.h:203
#define D4D_COLOR_GET_B(color)
Definition: d4d_scheme.h:438
struct D4D_SCREEN_S * pScreen
pointer to object screen owner - it is placed in RAM bacause one object could be used in multiply scr...
Definition: d4d_object.h:146
#define D4D_COLOR_SLDR_BAR_START
This is slider start fore color definition. If not defined, it sets to D4D_COLOR_GREEN as a default...
Definition: d4d_slider.h:129
D4D_OBJECT_DATA_PTR pData
Pointer on runtime object data.
Definition: d4d_object.h:180
D4D_COLOR D4D_ObjectGetForeFillColor(D4D_OBJECT *pObj)
Function return object current fill fore color.
Definition: d4d_scheme.c:208
#define D4D_COLOR_BCKG_CAPTURE
This is background object color in captured state of object. If not defined, it sets to D4D_COLOR_GRE...
Definition: d4d_scheme.h:167
D4D_COLOR fore
The object fore color in standard state.
Definition: d4d_scheme.h:585
#define D4D_COLOR_SCR_DESKTOP
This is desktop screen color. If not defined, it sets to D4D_COLOR_WHITE as a default.
Definition: d4d_scheme.h:173
#define D4D_COLOR_RGB(R, G, B)
Definition: d4d_scheme.h:434
#define D4D_COLOR_SCR_EXIT_BTN_FORE
This is screen exit button fore color. If not defined, it sets to D4D_COLOR_WHITE as a default...
Definition: d4d_scheme.h:197
#define D4D_COLOR_PRGRS_BAR_BAR_BCKG
This is progress bar background color definition. If not defined, it sets to D4D_COLOR_BRIGHT_GREY as...
D4D Driver main header file.
struct D4D_CLR_SCHEME_S * clrScheme
Pointer on used color scheme.
Definition: d4d_object.h:179
D4D Driver private header file.
This is the main structure of the color scheme in the D4D. It contains all the necessary colors to ru...
Definition: d4d_scheme.h:578
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
D4D_CLR_SCHEME * D4D_ScreenGetScheme(D4D_SCREEN *pScreen)
D4D_COLOR D4D_ChangeColorIntesity(D4D_COLOR color, sByte intensity)
Compute change of color intesity.
Definition: d4d_scheme.c:286
#define D4D_COLOR_PRGRS_BAR_BAR_END
This is progress bar end color definition. If not defined, it sets to D4D_COLOR_YELLOW as a default...
#define D4D_COLOR_SLDR_BAR_BCKG
This is slider background color definition. If not defined, it sets to D4D_COLOR_BRIGHT_GREY as a def...
Definition: d4d_slider.h:123
#define D4D_COLOR_SCR_TILTLETEXT
This is title text screen color. If not defined, it sets to D4D_COLOR_WHITE as a default.
Definition: d4d_scheme.h:191
#define D4D_OBJECT_DRAWFLAGS_CAPTURING
Draw capturing state flag.
Definition: d4d_base.h:363
#define D4D_COLOR_SCR_OUTLINE
This is outline screen color. If not defined, it sets to D4D_COLOR_LIGHT_GREY as a default...
Definition: d4d_scheme.h:179
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
D4D_CLR_SCHEME * D4D_ObjectGetScheme(D4D_OBJECT *pObj)
Function return the pointer to current use object scheme of object.
Definition: d4d_scheme.c:109
#define D4D_COLOR_SCR_TITLEBAR
This is title bar screen color. If not defined, it sets to D4D_COLOR_ORANGE as a default.
Definition: d4d_scheme.h:185
D4D_COLOR bckgFocus
The object background color in focused state.
Definition: d4d_scheme.h:583
void D4D_SetDefaultScheme(D4D_CLR_SCHEME *pScheme)
Function sets the new default color scheme.
Definition: d4d_scheme.c:145
#define D4D_COLOR_BCKG_DISABLED
This is background object color in disabled state of object. If not defined, it sets to D4D_COLOR_LIG...
Definition: d4d_scheme.h:143
signed short sWord
Type definition of sWord (signed 16-bit).
Definition: d4d_types.h:163
#define D4D_COLOR_FORE_CAPTURE
This is fore object color in captured state of object. If not defined, it sets to D4D_COLOR_BRIGHT_RE...
Definition: d4d_scheme.h:161
Byte D4D_MulDivUU8(Byte u1, Byte u2, Byte d)
Simple proportion unsigned calculation - 8 bit.
Definition: d4d_math.c:206
#define D4D_COLOR_GAUG_HUB
This is default gauge hub color definition. If not defined, it sets to D4D_COLOR_DARK_RED as a defaul...
Definition: d4d_gauge.h:67
#define D4D_COLOR_SLDR_BAR_FORE
This is slider fore color definition. If not defined, it sets to D4D_COLOR_DARK_BLUE as a default...
Definition: d4d_slider.h:117
#define D4D_COLOR_GAUG_POINTER
This is default gauge pointer color definition. If not defined, it sets to D4D_COLOR_DARK_BLUE as a d...
Definition: d4d_gauge.h:73
D4D_CLR_SCHEME * D4D_GetDefaultScheme(void)
Function return the pointer to default color scheme.
Definition: d4d_scheme.c:133
The object main structure type definition.
Definition: d4d_object.h:167
signed char sByte
Type definition of sByte (signed 8-bit).
Definition: d4d_types.h:155
D4D_OBJECT_RELATIONS pRelations
Relationship between the objects.
Definition: d4d_object.h:177
#define D4D_COLOR_GRAPH_GRID
This is default graph grid color definition. If not defined, it sets to D4D_COLOR_LIGHT_GREY as a def...
Definition: d4d_graph.h:73
#define D4D_COLOR_CHECKBOX_ICON_BCKG
This is check box icon background color definition. Is used for example if non-check icon is not defi...
Definition: d4d_check_box.h:72
#define D4D_DECLARE_CLR_SCHEME(name, scrDesktop, scrOutline, scrTitleBar, scrTitleText, scrExitBtnFore, scrExitBtnBckg, objBckg, objBckgDis, objBckgFocus, objBckgCapture, objFore, objForeDis, objForeFocus, objForeCapture, gaugHub, gaugPointer, sldrBarBckg, sldrBar, sldrBarStart, sldrBarEnd, iconBckg, graphGrid, prgrsBarBarBckg, prgrsBarBar, prgrsBarBarEnd)
The color scheme has a simple instantiation macro that specifies all colors for screens, common object colors, and object dependent colors. This is a full definition macro that allows setting of all colors in D4D color scheme.
Definition: d4d_scheme.h:635
#define D4D_COLOR_GET_G(color)
Definition: d4d_scheme.h:437
#define D4D_COLOR_FORE_NORM
This is fore object color in normal state of object. If not defined, it sets to D4D_COLOR_BLACK as a ...
Definition: d4d_scheme.h:125
Byte D4D_Abs(sByte num)
Calculation of absolute value - 8 bit.
Definition: d4d_math.c:306
#define D4D_COLOR_FORE_FOCUS
This is fore object color in focused state of object. If not defined, it sets to D4D_COLOR_RED as a d...
Definition: d4d_scheme.h:149
The screen structure type. The main screen structure that contains all needed data to run the eGUI sc...
Definition: d4d_screen.h:162
D4D_COLOR bckg
The object background color in standard state.
Definition: d4d_scheme.h:581
D4D_COLOR bckgCapture
The object background color in captured state.
Definition: d4d_scheme.h:584
#define D4D_COLOR_FORE_DISABLED
This is fore object color in disabled state of object. If not defined, it sets to D4D_COLOR_GREY as a...
Definition: d4d_scheme.h:137
Byte D4D_OBJECT_DRAWFLAGS
Drawing object flags type, handled to object in D4D_MSG_DRAW events.
Definition: d4d_base.h:359
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
#define D4D_COLOR_BCKG_FOCUS
This is background object color in focused state of object. If not defined, it sets to D4D_COLOR_LIGH...
Definition: d4d_scheme.h:155
#define D4D_COLOR_PRGRS_BAR_BAR_FORE
This is progress bar fore color definition. If not defined, it sets to D4D_COLOR_DARK_GREEN as a defa...
D4D_COLOR D4D_GetGreyScale(D4D_COLOR color)
Compute the grayscale color.
Definition: d4d_scheme.c:333
#define D4D_COLOR_BCKG_NORM
This is background object color in normal state of object. If not defined, it sets to D4D_COLOR_WHITE...
Definition: d4d_scheme.h:131
D4D_COLOR bckgDis
The object background color in disabled state.
Definition: d4d_scheme.h:582
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159
D4D_COLOR foreFocus
The object fore color in focused state.
Definition: d4d_scheme.h:587
#define D4D_COLOR_GET_R(color)
Definition: d4d_scheme.h:436
D4D_COLOR foreCapture
The object fore color in captured state.
Definition: d4d_scheme.h:588
D4D_BOOL D4D_IsEnabled(D4D_OBJECT *pObject)
Function find out if the object is enabled or not.
Definition: d4d_object.c:303
#define D4D_COLOR_SLDR_BAR_END
This is slider end color definition. If not defined, it sets to D4D_COLOR_RED as a default...
Definition: d4d_slider.h:135