eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_slider.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 //Internal API
50 void D4D_SldrOnMessage(D4D_MESSAGE* pMsg);
52 
54 {
55  D4D_DEFSTR("Slider"),
57  NULL,
59 };
60 
61 // temporary structure for bar coordinate calculation
62 typedef struct
63 {
64  D4D_POINT position;
65  D4D_GEOMETRY contentGeom;
66  D4D_GEOMETRY bar1Geom;
67  D4D_GEOMETRY bar2Geom;
68  D4D_GEOMETRY bar3Geom;
69  D4D_DIRECTION dir;
70  D4D_BOOL isHorizontal;
71  D4D_COOR inner_radius;
72  D4D_COOR bar_radius;
73 } D4D_SLIDER_TMP_VAL;
74 
75 
76 
77 #define _calc (*((D4D_SLIDER_TMP_VAL*)d4d_scratchPad))
78 
80 
81 /*******************************************************
82 *
83 * calculate pointer endpoint from basepoint, limits and value
84 *
85 *******************************************************/
86 
87 static void D4D_SldrValue2Coor(D4D_OBJECT* pThis)
88 {
89  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
90  D4D_COOR barMin;
91  D4D_COOR barMax;
92  D4D_COOR c1, c2;
93  D4D_POINT tmpBarOff = pSldr->barOff;
94  sWord tmp_scale = (sWord)(pSldr->pData->limits.valueMax - pSldr->pData->limits.valueMin);
95 
96  _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position);
97  D4D_ComputeGeometry(&(_calc.contentGeom), pThis);
98 
99  if(tmp_scale < 0)
100  tmp_scale *= -1;
101 
102  if(pThis->size.cx > pThis->size.cy)
103  _calc.isHorizontal = D4D_TRUE;
104  else
105  _calc.isHorizontal = D4D_FALSE;
106 
107  _calc.bar1Geom.sz = pSldr->barSize;
108 
109  if(_calc.isHorizontal)
110  {
111  if(!tmpBarOff.x)
112  tmpBarOff.x = D4D_SLDR_BAR_OFF_LENGTH;
113 
114  if(!tmpBarOff.y)
115  tmpBarOff.y = D4D_SLDR_BAR_OFF_WIDTH;
116  }
117  else
118  {
119  if(!tmpBarOff.x)
120  tmpBarOff.x = D4D_SLDR_BAR_OFF_WIDTH;
121 
122  if(!tmpBarOff.y)
123  tmpBarOff.y = D4D_SLDR_BAR_OFF_LENGTH;
124  }
125 
126  if(!_calc.bar1Geom.sz.cx)
127  _calc.bar1Geom.sz.cx = (D4D_COOR)(_calc.contentGeom.sz.cx - (tmpBarOff.x * 2));
128 
129  if(!_calc.bar1Geom.sz.cy)
130  _calc.bar1Geom.sz.cy = (D4D_COOR)(_calc.contentGeom.sz.cy - (tmpBarOff.y * 2));
131 
132  _calc.bar1Geom.pnt = _calc.contentGeom.pnt;
133  _calc.bar1Geom.pnt.x += tmpBarOff.x;
134  _calc.bar1Geom.pnt.y += tmpBarOff.y;
135 
136  // horizontal?
137  if(_calc.isHorizontal)
138  {
139  barMin = (D4D_COOR)(_calc.bar1Geom.pnt.x);
140  barMax = (D4D_COOR)(barMin + _calc.bar1Geom.sz.cx - 1);
141  }
142  // vertical?
143  else
144  {
145  barMin = (D4D_COOR)(_calc.bar1Geom.pnt.y);
146  barMax = (D4D_COOR)(barMin + _calc.bar1Geom.sz.cy - 1);
147  }
148 
149 
150  // value and origin coordinates
151  c1 = D4D_MulDivUU((D4D_COOR)(pSldr->pData->limits.valueOrg - pSldr->pData->limits.valueMin), (D4D_COOR)(barMax-barMin),
152  (D4D_COOR)tmp_scale);
153 
154  c2 = D4D_MulDivUU((D4D_COOR)(pSldr->pData->value - pSldr->pData->limits.valueMin), (D4D_COOR)(barMax-barMin),
155  (D4D_COOR)tmp_scale);
156 
157 
158  #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
159  if(tmpBarOff.x > tmpBarOff.y)
160  tmp_scale = (sWord)(tmpBarOff.x - tmpBarOff.y);
161  else
162  tmp_scale = (sWord)(tmpBarOff.y - tmpBarOff.x);
163 
164  tmp_scale /=2;
165 
166  tmp_scale = (sWord)(pThis->radius - tmp_scale);
167 
168  if(tmp_scale > 0)
169  _calc.inner_radius = (D4D_COOR)tmp_scale;
170  else
171  _calc.inner_radius = 0;
172 
173  _calc.bar_radius = _calc.inner_radius;
174 
175  #endif
176 
177 
178  // bar rectangle range need to be "sorted"
179  if(c1 > c2)
180  {
181  D4D_COOR tmp_coor;
182  tmp_coor = c2;
183  c2 = c1;
184  c1 = tmp_coor;
185  }
186 
187  _calc.bar3Geom.sz = _calc.bar2Geom.sz = _calc.bar1Geom.sz;
188 
189  // X grows to right, Y grows to top
190  if(_calc.isHorizontal)
191  {
192 
193  if(pSldr->pData->limits.valueOrg > pSldr->pData->value)
194  _calc.dir = D4D_DIR_LEFT;
195  else
196  _calc.dir = D4D_DIR_RIGHT;
197 
198  _calc.bar3Geom.sz.cx -= c2;
199  _calc.bar1Geom.sz.cx = c1;
200  _calc.bar2Geom.sz.cx = (D4D_COOR)(c2 - c1 + 1);
201 
202  _calc.bar2Geom.pnt.x = (D4D_COOR)(_calc.bar1Geom.pnt.x + c1);
203  _calc.bar2Geom.pnt.y = _calc.bar1Geom.pnt.y;
204 
205  _calc.bar3Geom.pnt.x = (D4D_COOR)(_calc.bar1Geom.pnt.x + c2);
206  _calc.bar3Geom.pnt.y = _calc.bar1Geom.pnt.y;
207 
208  #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
209 
210  if(_calc.inner_radius)
211  {
212  _calc.bar1Geom.sz.cx += _calc.inner_radius * 2;
213  _calc.bar3Geom.sz.cx += _calc.inner_radius * 2;
214 
215  _calc.bar_radius = D4D_LimitU(_calc.bar_radius, 0, (D4D_COOR)(_calc.bar2Geom.sz.cx / 2));
216 
217  if(_calc.inner_radius != _calc.bar_radius)
218  {
219  D4D_COOR tmp_coor;
220 
221  //tmp_coor = D4D_RndCornerGetNonPrintedPxl(_calc.inner_radius, (D4D_COOR)(_calc.pnt2.x + _calc.sz2.cx - (_calc.pnt1.x + _calc.sz1.cx + 0)));
222  tmp_coor = (D4D_COOR)(_calc.inner_radius - D4D_RndCornerGetNonPrintedPxl((D4D_COOR)(_calc.inner_radius + 1), (D4D_COOR)(_calc.inner_radius - (_calc.bar2Geom.sz.cx / 2))));
223 
224  _calc.bar2Geom.sz.cy -= (D4D_COOR)(tmp_coor*2);
225  _calc.bar2Geom.pnt.y += tmp_coor;
226  }
227 
228  _calc.bar1Geom.sz.cx = D4D_LimitU(_calc.bar1Geom.sz.cx, (D4D_COOR)(_calc.inner_radius * 2), (D4D_COOR)(barMax - barMin + 1));
229  _calc.bar3Geom.sz.cx = D4D_LimitU(_calc.bar3Geom.sz.cx, (D4D_COOR)(_calc.inner_radius * 2), (D4D_COOR)(barMax - barMin + 1));
230 
231  _calc.bar3Geom.pnt.x -= (D4D_COOR)(2 * _calc.inner_radius);
232  _calc.bar3Geom.pnt.x = D4D_LimitU(_calc.bar3Geom.pnt.x, _calc.bar1Geom.pnt.x, (D4D_COOR)(barMax- (_calc.inner_radius * 2)));
233  }
234  #endif
235 
236  }else
237  {
238 
239  if(pSldr->pData->limits.valueOrg > pSldr->pData->value)
240  _calc.dir = D4D_DIR_DOWN;
241  else
242  _calc.dir = D4D_DIR_UP;
243 
244  _calc.bar3Geom.pnt = _calc.bar2Geom.pnt = _calc.bar1Geom.pnt;
245 
246  _calc.bar2Geom.pnt.y += (D4D_COOR)(_calc.bar1Geom.sz.cy - (c2 + 1));
247 
248  _calc.bar1Geom.pnt.y += (D4D_COOR)(_calc.bar1Geom.sz.cy - (c1 + 1));
249 
250  _calc.bar3Geom.sz.cy = (D4D_COOR)(_calc.bar1Geom.sz.cy - (c2 + 1));
251  _calc.bar1Geom.sz.cy = (D4D_COOR)(c1 + 1);
252  _calc.bar2Geom.sz.cy = (D4D_COOR)(c2 - c1 + 1);
253 
254  #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
255 
256  if(_calc.inner_radius)
257  {
258  _calc.bar1Geom.sz.cy += (D4D_COOR)(_calc.inner_radius * 2);
259  _calc.bar3Geom.sz.cy += (D4D_COOR)(_calc.inner_radius * 2);
260 
261  _calc.bar_radius = D4D_LimitU(_calc.bar_radius, 0, (D4D_COOR)(_calc.bar2Geom.sz.cy / 2));
262 
263  if(_calc.inner_radius != _calc.bar_radius)
264  {
265  D4D_COOR tmp_coor;
266 
267  tmp_coor = (D4D_COOR)(_calc.inner_radius - D4D_RndCornerGetNonPrintedPxl((D4D_COOR)(_calc.inner_radius + 1), (D4D_COOR)(_calc.inner_radius - (_calc.bar2Geom.sz.cy / 2))));
268 
269  _calc.bar2Geom.sz.cx -= (D4D_COOR)(tmp_coor * 2);
270  _calc.bar2Geom.pnt.x += tmp_coor;
271  }
272 
273  _calc.bar1Geom.sz.cy = D4D_LimitU(_calc.bar1Geom.sz.cy, (D4D_COOR)(_calc.inner_radius * 2 + 1), (D4D_COOR)(barMax - barMin + 1));
274  _calc.bar3Geom.sz.cy = D4D_LimitU(_calc.bar3Geom.sz.cy, (D4D_COOR)(_calc.inner_radius * 2), (D4D_COOR)(barMax - barMin + 1));
275 
276  _calc.bar1Geom.pnt.y -= (D4D_COOR)(2 * _calc.inner_radius);
277  _calc.bar1Geom.pnt.y = D4D_LimitU(_calc.bar1Geom.pnt.y, _calc.bar3Geom.pnt.y, (D4D_COOR)(barMax - (_calc.inner_radius * 2)));
278  }
279  #endif
280  }
281 
282 
283 }
284 
285 
286 /*******************************************************
287 *
288 * SLIDER Drawing routine
289 *
290 *******************************************************/
291 
292 static void D4D_SldrOnDraw(D4D_MESSAGE* pMsg)
293 {
294  D4D_OBJECT* pThis = pMsg->pObject;
295  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
296  D4D_COLOR clrT, clrB;
297  D4D_COLOR clrBar = pSldr->pData->colorBar;
299 
300  D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
301 
302  #ifdef D4D_DEBUG
303  // sanity check
305  #endif
306 
307  // bar coordinate calculation
308  D4D_SldrValue2Coor(pThis);
309 
310  clrT = D4D_ObjectGetForeColor(pThis, draw);
311  clrB = D4D_ObjectGetBckgColor(pThis, draw);
312 
313  // if slider is disabled draw slider in grey scale
314  if(!D4D_IsEnabled(pThis))
315  {
316  clrBar = D4D_GetGreyScale(clrBar);
317  clrBarBckg = D4D_GetGreyScale(clrBarBckg);
318  }
319 
320 
321 
322  // when background redraw is needed
324  {
325  // draw the bitmap
326  if(pSldr->pBmpBkgd != NULL)
327  D4D_DrawRBmp(&_calc.position, pSldr->pBmpBkgd, (D4D_BOOL)!D4D_IsEnabled(pThis), pThis->radius);
328  else
329  D4D_FillRRect(&_calc.position, &pThis->size, D4D_ObjectGetBckgFillColor(pThis), pThis->radius);
330  }
331 
332  // draw focus rectangle
333  D4D_RRect(&_calc.position, &pThis->size, D4D_LINE_THIN, clrT, pThis->radius);
334 
335  // draw first inactive part
336  D4D_FillRRect(&_calc.bar1Geom.pnt, &_calc.bar1Geom.sz, clrBarBckg, _calc.inner_radius);
337 
338  // draw last inactive part of the bar
339  D4D_FillRRect(&_calc.bar3Geom.pnt, &_calc.bar3Geom.sz, clrBarBckg, _calc.inner_radius);
340 
341  // draw active part of the bar
342  if(pSldr->pData->value != 0)
343  {
345  D4D_FillRRectColorScale(&_calc.bar2Geom.pnt, &_calc.bar2Geom.sz, D4D_COLOR_SLDR_BAR_START, clrBar, _calc.dir, _calc.bar_radius);
346  else
347  D4D_FillRRect(&_calc.bar2Geom.pnt, &_calc.bar2Geom.sz, clrBar, _calc.inner_radius);
348  }
349  // Draw the frame
350  if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
351  D4D_DrawFrame(pThis, clrT, clrB);
352 
353 
354  // draw the text
355  if(pSldr->textBuff.pText != NULL)
356  {
357  D4D_SIZE tmp_size;
358 
359  _calc.position.x += pSldr->txtOff.x;
360  _calc.position.y += pSldr->txtOff.y;
361 
362  if(!pSldr->txtOff.x)
363  {
364  if(_calc.isHorizontal)
365  _calc.position.x += (D4D_COOR) ((_calc.contentGeom.sz.cx - (D4D_COOR)(D4D_GetTextWidth(pSldr->textBuff.fontId, pSldr->textBuff.pText))) / 2);
366  else
367  _calc.position.x += (D4D_COOR) (_calc.bar1Geom.pnt.x + 1);
368  }
369 
370  if(!pSldr->txtOff.y)
371  _calc.position.y += (D4D_COOR) (((_calc.contentGeom.sz.cy - D4D_GetFontHeight(pSldr->textBuff.fontId)) / 2) + 1);
372 
374  clrT = (D4D_COLOR)(~clrBar);
375 
376  tmp_size.cx = D4D_GetTextWidth(pSldr->textBuff.fontId, pSldr->textBuff.pText);
377  tmp_size.cy = D4D_GetFontHeight(pSldr->textBuff.fontId);
378 
379 
380  D4D_DrawTextRect(&_calc.position, &tmp_size, &pSldr->textBuff, clrT, clrB);
381 
382  }
383 
384 }
385 
386 /*******************************************************
387 *
388 * SLIDER key handling routine
389 *
390 *******************************************************/
391 
392 static void D4D_SldrOnKeyUp(D4D_MESSAGE* pMsg)
393 {
394  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pMsg->pObject);
395  D4D_KEY_SCANCODE tmp_key = pMsg->prm.key;
396  // capture the keyboard if enter is pressed
397  if(tmp_key == D4D_KEY_SCANCODE_ENTER)
398  {
399  D4D_CaptureKeys(pMsg->pObject);
400  return;
401  }
402 
403  // exit capture
404  if(tmp_key == D4D_KEY_SCANCODE_ESC)
405  {
407  return;
408  }
409 
410 
411  if(D4D_GetCapturedObject() == pMsg->pObject)
412  {
413  // increment value
414  if((tmp_key == D4D_KEY_SCANCODE_RIGHT) || (tmp_key == D4D_KEY_SCANCODE_UP))
415  {
416  D4D_SldrChangeValue(pMsg->pObject, pSldr->pData->limits.step);
417  }
418  // decrement value
419  else if((tmp_key == D4D_KEY_SCANCODE_LEFT) || (tmp_key == D4D_KEY_SCANCODE_DOWN))
420  {
422  }
423  }
424 }
425 
426 /*******************************************************
427 *
428 * SLIDER Touched Button handling routine
429 *
430 *******************************************************/
431 #if defined(D4D_LLD_TCH) || defined(D4D_LLD_MOUSE)
432 static void D4D_SldrTouched(D4D_MESSAGE* pMsg, D4D_POINT* pPoint)
433 {
434  D4D_OBJECT* pThis = pMsg->pObject;
435  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
436 
437  if((D4D_GetFocusedObject(pMsg->pScreen) == pThis) || (pThis->pData->flags & D4D_OBJECT_F_FASTTOUCH))
438  {
439  D4D_FocusSet(pMsg->pScreen, pThis);
440 
441  if(D4D_GetCapturedObject() != pThis)
442  D4D_CaptureKeys(pThis);
443 
444  if(pThis->size.cx > pThis->size.cy)
445  {
446  if(pPoint->x > ((pThis->size.cx / 2) + pThis->position.x))
447  D4D_SldrChangeValue(pThis, pSldr->pData->limits.step);
448  else
450  }else
451  {
452 
453  if(pPoint->y < ((pThis->size.cy / 2) + pThis->position.y))
454  D4D_SldrChangeValue(pThis, pSldr->pData->limits.step);
455  else
457  }
458  }else
459  D4D_FocusSet(pMsg->pScreen, pThis);
460 
461 }
462 #endif
463 
465 {
466  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
467  Byte shade;
468  D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis);
469 
470  if(value >= pSldr->pData->limits.valueOrg)
471  shade = D4D_MulDivUU8((Byte)(value - pSldr->pData->limits.valueOrg), 255, \
472  (Byte)(pSldr->pData->limits.valueMax - pSldr->pData->limits.valueOrg));
473  else
474  shade = D4D_MulDivUU8((Byte)(pSldr->pData->limits.valueOrg - value), 255, \
475  (Byte)(pSldr->pData->limits.valueOrg - pSldr->pData->limits.valueMin));
476 
477  return D4D_GetCrossColor(pScheme_tmp->objectDepend.slider.barStart, pScheme_tmp->objectDepend.slider.barEnd, shade);
478 
479 }
480 
481 /******************************************************************************
482 * Begin of D4D_SLIDER public functions
483 */
487 /**************************************************************************/
495 {
496  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
497  D4D_SLIDER_DATA* pData = pSldr->pData;
498 
499  // keep value within limits
500 
501  value = D4D_LimitS8(value, pData->limits.valueMin, pData->limits.valueMax);
502 
503  if(pData->value == value)
504  return ;
505 
506  // remember new value
507  pData->value = value;
508 
510  pData->colorBar = D4D_SldrComputeColorBar((D4D_OBJECT*)pThis, value);
511 
513 
514  // notify user that the value has changed
515  if(pSldr->OnValueChanged)
516  pSldr->OnValueChanged((D4D_OBJECT*)pThis);
517 }
518 
519 /**************************************************************************/
526 {
527  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
528  return pSldr->pData->value;
529 }
530 
531 /**************************************************************************/
539 {
540  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
541  D4D_SLIDER_DATA* pData = pSldr->pData;
542 
544  return;
545 
546  if(pData->colorBar == color)
547  return ;
548 
549  // remember new color
550  pData->colorBar = color;
551 
553 }
554 
556 {
557  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
558  return pSldr->pData->colorBar;
559 }
560 
561 
562 /**************************************************************************/
570 {
571  D4D_SLIDER_VALUE value;
572 
573  // change the value
574  value = D4D_LimitS8((D4D_SLIDER_VALUE)(D4D_GET_SLIDER(pThis)->pData->value + incr), -128, 127);
575 
576  D4D_SldrSetValue(pThis, value);
577 }
578 
579 /**************************************************************************/
587 {
588  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
589  D4D_SLIDER_DATA* pData = pSldr->pData;
590 
591  pData->limits = *pLimits;
592 
593  if((pData->limits.valueOrg < pData->limits.valueMin) || (pData->limits.valueOrg >= pData->limits.valueMax))
594  pData->limits.valueOrg = pData->limits.valueMin;
595 
596  D4D_SldrSetValue(pThis, pData->value);
597 }
598 
599 /**************************************************************************/
607 {
608  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
609  *pLimits = pSldr->pData->limits;
610 }
611 
612 /******************************************************************************
613 * End of public functions */
615 /******************************************************************************/
616 /**************************************************************/
626 /*******************************************************
627 *
628 * The main SLIDER message handler
629 *
630 *******************************************************/
631 
633 {
634  D4D_OBJECT* pThis = pMsg->pObject;
635  D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis);
636 
637  #if defined(D4D_LLD_TCH)
638  static D4D_INDEX autoTouchTicks;
639  #endif
640 
641  #if defined(D4D_LLD_MOUSE)
642  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
643  #endif
644 
645  #if defined(D4D_LLD_TCH) || defined(D4D_LLD_MOUSE)
646  D4D_POINT touchClickPoint;
647  #endif
648 
649  switch(pMsg->nMsgId)
650  {
651  case D4D_MSG_DRAW:
652  D4D_SldrOnDraw(pMsg);
653  break;
654 
655  case D4D_MSG_KEYUP:
656  D4D_SldrOnKeyUp(pMsg);
657  break;
658 
659  case D4D_MSG_KILLFOCUS:
661  break;
662 
663  case D4D_MSG_ONINIT:
664  pThis->pData->flags &= ~D4D_OBJECT_F_NOTINIT;
665 
667  D4D_GET_SLIDER(pThis)->pData->colorBar = pScheme_tmp->objectDepend.slider.barFore;
668  else
669  D4D_GET_SLIDER(pThis)->pData->colorBar = D4D_SldrComputeColorBar(pThis, D4D_GET_SLIDER(pThis)->pData->value);
670  break;
671 
672 #ifdef D4D_LLD_MOUSE
674  touchClickPoint = D4D_GetMouseCoordinates(pMsg->pObject);
675  D4D_SldrTouched(pMsg, &touchClickPoint);
676  break;
677 
679  D4D_SldrChangeValue(pThis, pSldr->pData->limits.step);
680  break;
681 
683  D4D_SldrChangeValue(pThis, -pSldr->pData->limits.step);
684  break;
685 #endif
686 
687 
688 
689 #ifdef D4D_LLD_TCH
690  case D4D_MSG_TOUCH_AUTO:
692  break;
693 
694  if(autoTouchTicks--)
695  break;
696 
697  case D4D_MSG_TOUCHED:
698  autoTouchTicks = D4D_SLDR_AUTOTOUCHTICKS;
699  touchClickPoint = D4D_GetTouchScreenCoordinates(pMsg->pObject);
700  D4D_SldrTouched(pMsg, &touchClickPoint);
701  break;
702 #endif
703  default:
704  // call the default behavior of all objects
705  D4D_ObjOnMessage(pMsg);
706  }
707 }
708 
709 /**************************************************************/
715 {
716  return &(D4D_GET_SLIDER(pThis)->textBuff);
717 }
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
const D4D_BMP * pBmpBkgd
Definition: d4d_slider.h:189
#define D4D_KEY_SCANCODE_ESC
This macro is used to specify Key Scan Code ESC. If not defined, it sets to 0x01 as a default...
Definition: d4d_base.h:305
#define D4D_KEY_SCANCODE_RIGHT
This macro is used to specify Key Scan Code RIGHT. If not defined, it sets to 0x4D as a default...
Definition: d4d_base.h:295
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_KEY_SCANCODE_UP
This macro is used to specify Key Scan Code UP. If not defined, it sets to 0x51 as a default...
Definition: d4d_base.h:280
static D4D_COLOR D4D_SldrComputeColorBar(D4D_OBJECT *pThis, D4D_SLIDER_VALUE value)
Definition: d4d_slider.c:464
D4D_CLR_SCHEME_OBJ objectDepend
Sub structure of object non standard colors.
Definition: d4d_scheme.h:589
sByte D4D_SLIDER_VALUE
Type definition of slider value type - this is standard type used for slider data input...
Definition: d4d_slider.h:148
Type definition of eGUI point structure.
Definition: d4d_types.h:223
D4D_SLIDER_VALUE valueMin
minimal value - &lt;-128..valueMax&gt;
Definition: d4d_slider.h:153
On Init message - is send for first time when the object is inicialized.
Definition: d4d_base.h:370
D4D object messages structure.
Definition: d4d_base.h:400
#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 barFore
The slider bar fore color.
Definition: d4d_scheme.h:534
D4D_SLIDER_VALUE valueOrg
bar origin value (should be valueMin &lt;= org &lt;= valueMax)
Definition: d4d_slider.h:156
Mouse Whell Move Down message - is send in case that mouse whell move down is detected on this object...
Definition: d4d_base.h:390
#define D4D_FALSE
This is definition of boolean operation value in eGUI - FALSE.
Definition: d4d_types.h:104
The string type. This structure contains all properties about string in eGUI.
Definition: d4d_string.h:100
void D4D_SldrChangeValue(D4D_OBJECT_PTR pThis, D4D_SLIDER_VALUE incr)
Function change the slider value by signed increment.
Definition: d4d_slider.c:569
#define D4D_DrawRBmp(ppt, pBmp, greyScale, radius)
Definition: d4d.h:192
D4D_OBJECT_INITFLAGS initFlags
The initializations object flags.
Definition: d4d_object.h:178
#define D4D_DrawTextRect(ppt, psz, buffText, colorText, colorBkgd)
Function that draw text into defined rectangle on the screen.
static void D4D_SldrOnDraw(D4D_MESSAGE *pMsg)
Definition: d4d_slider.c:292
D4D_COLOR barEnd
The slider bar fore end color for case that the D4D_SLDR_F_BAR_SCALECOLOR flag is enabled...
Definition: d4d_scheme.h:536
D4D_SLIDER_VALUE value
Definition: d4d_slider.h:176
D4D_FONT fontId
index of used font
Definition: d4d_string.h:104
D4D_SLDR_ON_CHANGE OnValueChanged
Definition: d4d_slider.h:190
void D4D_SldrSetValue(D4D_OBJECT_PTR pThis, D4D_SLIDER_VALUE value)
Function Sets the slider value.
Definition: d4d_slider.c:494
D4D_POINT D4D_GetTouchScreenCoordinates(D4D_OBJECT *pObject)
#define D4D_TRUE
This is definition of boolean operation value in eGUI - TRUE.
Definition: d4d_types.h:106
void D4D_DrawFrame(D4D_OBJECT *pObject, D4D_COLOR clrT, D4D_COLOR clrB)
Function draw standard object frame based on the object settings and current state.
void D4D_SldrSetBarColor(D4D_OBJECT_PTR pThis, D4D_COLOR color)
Function Sets the slider bar color.
Definition: d4d_slider.c:538
#define _calc
Definition: d4d_slider.c:77
D4D_SLIDER_VALUE valueMax
maximal value - &lt;valueMin..127&gt;
Definition: d4d_slider.h:154
struct D4D_OBJECT_S * pObject
Pointer to object who is receiver of this message. If the receiver is just screen this field must be ...
Definition: d4d_base.h:402
D4D_COLOR colorBar
Definition: d4d_slider.h:178
Key Up message - is send when the object get new Key Up event.
Definition: d4d_base.h:377
D4D Driver main header file.
#define D4D_KEY_SCANCODE_ENTER
This macro is used to specify Key Scan Code ENTER. If not defined, it sets to 0x1C as a default...
Definition: d4d_base.h:300
D4D_OBJECT_FLAGS flags
runtime object flags
Definition: d4d_object.h:145
D4D_COLOR barBckg
The slider bar background color.
Definition: d4d_scheme.h:533
Auto Touched message - is send when the object is still keep touch by touch screen driver ...
Definition: d4d_base.h:380
Direction UP.
Definition: d4d_types.h:309
#define D4D_GetMouseCoordinates(pObject)
Definition: d4d_mouse.h:226
void D4D_SldrGetLimits(D4D_OBJECT_PTR pThis, D4D_SLIDER_LIMITS *pLimits)
Function get the current limits of slider object.
Definition: d4d_slider.c:606
#define D4D_OBJECT_DRAWFLAGS_COMPLETE
Draw complete flag.
Definition: d4d_base.h:361
sByte D4D_LimitS8(sByte val, sByte min, sByte max)
Calculation of limitation value (signed) - 8 bit.
Definition: d4d_math.c:448
#define D4D_SCRATCHPAD_SIZE
Call back function raised by any new input event (touch, mouse, keys).
Definition: d4d_base.h:579
Mouse Left Button Release message - is send in case that mouse left release is detected on this objec...
Definition: d4d_base.h:384
D4D Driver private header file.
#define D4D_KEY_SCANCODE_DOWN
This macro is used to specify Key Scan Code DOWN. If not defined, it sets to 0x50 as a default...
Definition: d4d_base.h:285
#define D4D_DEFSTR(str)
Macro that helps declare the strings in eGUI.
Definition: d4d_string.h:246
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
#define D4D_SLDR_BAR_OFF_WIDTH
This is slider working bar offset in axis Y to object outline. If not defined, it sets to 2 pixels as...
Definition: d4d_slider.h:104
Direction RIGHT.
Definition: d4d_types.h:311
D4D_SLIDER_VALUE step
step value of slider change
Definition: d4d_slider.h:155
D4D_COOR cx
Size in axis X (width)
Definition: d4d_types.h:232
static void D4D_SldrOnKeyUp(D4D_MESSAGE *pMsg)
Definition: d4d_slider.c:392
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
D4D_POINT position
Position on the screen/object.
Definition: d4d_object.h:169
void D4D_SldrOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_slider.c:632
D4D_SIZE barSize
Definition: d4d_slider.h:188
#define D4D_OBJECT_DRAWFLAGS_STATE
Draw just change of state flag.
Definition: d4d_base.h:364
D4D_COOR radius
Object corners radius.
Definition: d4d_object.h:171
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
void D4D_ObjOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_object.c:443
D4D_POINT txtOff
Definition: d4d_slider.h:186
static void D4D_SldrValue2Coor(D4D_OBJECT *pThis)
Definition: d4d_slider.c:87
void D4D_FocusSet(const D4D_SCREEN *pScreen, D4D_OBJECT_PTR pObject)
The function set the obejct focus to new object.
Definition: d4d_screen.c:430
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
Direction LEFT.
Definition: d4d_types.h:312
#define D4D_SLDR_F_BAR_SCALECOLOR
This option enable little bit different type of drawing bar, the color is gradually changed from fore...
Definition: d4d_slider.h:71
#define D4D_ASSERT(cond)
Definition: d4d_base.h:583
D4D_CLR_SCHEME * D4D_ObjectGetScheme(D4D_OBJECT *pObj)
Function return the pointer to current use object scheme of object.
Definition: d4d_scheme.c:109
D4D_TCHAR * pText
pointer to text array
Definition: d4d_string.h:102
D4D_STRING * D4D_SldrGetTextBuffer(D4D_OBJECT *pThis)
Definition: d4d_slider.c:714
D4D_COOR y
Coordination in axis Y.
Definition: d4d_types.h:226
#define D4D_OBJECT_F_NOTINIT
Definition: d4d_object.h:113
#define D4D_GET_SLIDER(pObj)
Definition: d4d_slider.h:200
D4D_OBJECT_PTR D4D_GetFocusedObject(const D4D_SCREEN *pScreen)
The function returns pointer to object that is focused in given screen.
Definition: d4d_screen.c:266
D4D_MSGID nMsgId
Type of message.
Definition: d4d_base.h:404
D4D_SIZE size
Size of the object.
Definition: d4d_object.h:170
signed short sWord
Type definition of sWord (signed 16-bit).
Definition: d4d_types.h:163
void D4D_RRect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_LINETYPE ltype, D4D_COLOR color, D4D_COOR radius)
Function draw rectangle on the screen with round corners.
D4D_COOR D4D_RndCornerGetNonPrintedPxl(D4D_COOR radius, D4D_COOR line)
Function that counts number of printed pixels in specified line of circle quadrant.
D4D_COLOR D4D_SldrGetBarColor(D4D_OBJECT_PTR pThis)
Definition: d4d_slider.c:555
Byte D4D_MulDivUU8(Byte u1, Byte u2, Byte d)
Simple proportion unsigned calculation - 8 bit.
Definition: d4d_math.c:206
D4D_DIRECTION
Type definition of eGUI direction type.
Definition: d4d_types.h:307
#define D4D_KEY_SCANCODE_LEFT
This macro is used to specify Key Scan Code LEFT. If not defined, it sets to 0x4B as a default...
Definition: d4d_base.h:290
Type definition of slider limits structure.
Definition: d4d_slider.h:151
D4D_KEY_SCANCODE key
There will be stored only code of key without release / press information - is valid with D4D_MSG_KEY...
Definition: d4d_base.h:409
D4D_POINT D4D_GetClientToScreenPoint(D4D_OBJECT *pObject, D4D_POINT *nClientPoint)
The function convert client point on the screen to the global screen point.
Definition: d4d_screen.c:536
LWord D4D_INDEX
Type definition of eGUI general index variables.
Definition: d4d_types.h:206
The object main structure type definition.
Definition: d4d_object.h:167
void D4D_CaptureKeys(D4D_OBJECT_PTR pObj)
Function switch on capturing the keys to objects.
Definition: d4d_object.c:190
Draw message - is send when the object should be redrawed.
Definition: d4d_base.h:371
D4D_CLR_SCHEME_SLDR slider
The non standard colors of slider object.
Definition: d4d_scheme.h:568
Direction DOWN.
Definition: d4d_types.h:310
void D4D_ComputeGeometry(D4D_GEOMETRY *pGeometry, D4D_OBJECT *pObject)
Definition: d4d_base.c:1047
D4D_COOR cy
Size in axis Y (height)
Definition: d4d_types.h:233
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
D4D_SLIDER_VALUE D4D_SldrGetValue(D4D_OBJECT_PTR pThis)
Function Gets the slider value.
Definition: d4d_slider.c:525
#define D4D_OBJECT_F_FASTTOUCH
Object has enabled fast touch screen capability. This option supports only a some objects (button...
Definition: d4d_object.h:76
D4D_COLOR barStart
The slider bar fore start color for case that the D4D_SLDR_F_BAR_SCALECOLOR flag is enabled...
Definition: d4d_scheme.h:535
Touched message - is send when the object is touched by touch screen driver.
Definition: d4d_base.h:379
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
const D4D_OBJECT_SYS_FUNCTION d4d_sliderSysFunc
Definition: d4d_slider.c:53
Type definition of eGUI size structure.
Definition: d4d_types.h:230
D4D_STRING textBuff
Definition: d4d_slider.h:185
D4D_COOR D4D_GetTextWidth(D4D_FONT ix, D4D_TCHAR *pText)
The function returns width of text in pixels.
Definition: d4d_string.c:357
D4D_OBJECT_DRAWFLAGS draw
Contains draw flags - is valid with D4D_MSG_DRAW and D4D_MSG_DRAWDONE message.
Definition: d4d_base.h:408
void D4D_FillRRect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_COLOR color, D4D_COOR radius)
Function draw filled rectangle on the screen with round corners.
Type definition of eGUI geometry structure.
Definition: d4d_types.h:237
Line type thin.
Definition: d4d_types.h:293
D4D_SLIDER_LIMITS limits
Definition: d4d_slider.h:177
#define D4D_LimitU
Definition: d4d_math.h:105
void D4D_FillRRectColorScale(D4D_POINT *ppt, D4D_SIZE *psz, D4D_COLOR startColor, D4D_COLOR endColor, D4D_DIRECTION direction, D4D_COOR radius)
Function draw filled rectangle with round corners with changing color (cross color from start to end ...
void D4D_SldrSetLimits(D4D_OBJECT_PTR pThis, const D4D_SLIDER_LIMITS *pLimits)
Function set the new limits of slider object.
Definition: d4d_slider.c:586
D4D_SLIDER_DATA * pData
Definition: d4d_slider.h:191
#define D4D_SLDR_AUTOTOUCHTICKS
This is slider timeout of auto increment for long touch (in ticks of eGUI time ticks - D4D_TimeTickPu...
Definition: d4d_slider.h:110
void D4D_InvalidateObject(D4D_OBJECT_PTR pObject, D4D_BOOL bComplete)
Function invalidate object to redraw on screen.
Definition: d4d_object.c:71
Byte D4D_KEY_SCANCODE
Type definition of eGUI keys scan code.
Definition: d4d_types.h:304
#define D4D_MulDivUU
Definition: d4d_math.h:103
Byte D4D_OBJECT_DRAWFLAGS
Drawing object flags type, handled to object in D4D_MSG_DRAW events.
Definition: d4d_base.h:359
#define D4D_SLDR_F_BAR_AUTOCOLOR
This flag specifies the behavior of the slider. If it is set, the color of a slider bar depends on th...
Definition: d4d_slider.h:69
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
struct D4D_SCREEN_S * pScreen
Pointer to screen who is receiver of this message.
Definition: d4d_base.h:403
D4D_COLOR D4D_GetGreyScale(D4D_COLOR color)
Compute the grayscale color.
Definition: d4d_scheme.c:333
D4D_POINT barOff
Definition: d4d_slider.h:187
D4D_FONT_SIZE D4D_GetFontHeight(D4D_FONT ix)
Definition: d4d_font.c:381
Mouse Whell Move Up message - is send in case that mouse whell move up is detected on this object...
Definition: d4d_base.h:389
#define D4D_SLDR_F_TEXT_AUTOCOLOR
Enable text autocolor based on current value (inverted color to bar color)
Definition: d4d_slider.h:70
D4D_COOR x
Coordination in axis X.
Definition: d4d_types.h:225
Kill Focus message - is send when the object is losing focus.
Definition: d4d_base.h:374
union D4D_MESSAGE_S::@0 prm
Additional data for some type of messages.
#define D4D_SLDR_F_AUTOTOUCH_OFF
This option disables auto touch events to prevent fast changing of slider for longer touches...
Definition: d4d_slider.h:72
D4D_BOOL D4D_IsEnabled(D4D_OBJECT *pObject)
Function find out if the object is enabled or not.
Definition: d4d_object.c:303
#define D4D_SLDR_BAR_OFF_LENGTH
This is slider working bar offset in axis X to object outline. If not defined, it sets to 2 pixels as...
Definition: d4d_slider.h:98
D4D_OBJECT * D4D_GetCapturedObject(void)
Function returns the current keys capturing object pointer.
Definition: d4d_object.c:241