eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_slider.h
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 #ifndef __D4D_SLIDER_H
47 #define __D4D_SLIDER_H
48 
50 
51 /******************************************************************************
52 * D4D SLIDER setting constants
53 *
54 */
58 //********************* Slider flags for its specific flags *****************
69 #define D4D_SLDR_F_BAR_AUTOCOLOR (0x01 << D4D_OBJECT_F_OBJECT_SHIFT)
70 #define D4D_SLDR_F_TEXT_AUTOCOLOR (0x02 << D4D_OBJECT_F_OBJECT_SHIFT)
71 #define D4D_SLDR_F_BAR_SCALECOLOR (0x04 << D4D_OBJECT_F_OBJECT_SHIFT)
72 #define D4D_SLDR_F_AUTOTOUCH_OFF (0x08 << D4D_OBJECT_F_OBJECT_SHIFT)
73 
74 #define D4D_SLDR_F_AUTOCOLOR (D4D_SLDR_F_BAR_AUTOCOLOR | D4D_SLDR_F_TEXT_AUTOCOLOR)
75 
79 #ifndef D4D_SLDR_F_DEFAULT
80  #define D4D_SLDR_F_DEFAULT (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_TOUCHENABLE | D4D_OBJECT_F_FOCUSRECT | D4D_OBJECT_F_MOUSE_NORMAL)
81 #endif
82 
85 #ifndef D4D_SLDR_TXT_PRTY_DEFAULT
86  #define D4D_SLDR_TXT_PRTY_DEFAULT (D4D_ALIGN_H_CENTER_MASK | D4D_ALIGN_V_CENTER_MASK)
87 #endif
88 
91 #ifndef D4D_SLDR_FNT_PRTY_DEFAULT
92  #define D4D_SLDR_FNT_PRTY_DEFAULT ( D4D_FNT_PRTY_TRANSPARENT_YES_MASK )
93 #endif
94 
97 #ifndef D4D_SLDR_BAR_OFF_LENGTH
98  #define D4D_SLDR_BAR_OFF_LENGTH 2
99 #endif
100 
103 #ifndef D4D_SLDR_BAR_OFF_WIDTH
104  #define D4D_SLDR_BAR_OFF_WIDTH 4
105 #endif
106 
109 #ifndef D4D_SLDR_AUTOTOUCHTICKS
110  #define D4D_SLDR_AUTOTOUCHTICKS 10
111 #endif
112 
113 
116 #ifndef D4D_COLOR_SLDR_BAR_FORE
117  #define D4D_COLOR_SLDR_BAR_FORE D4D_COLOR_DARK_BLUE
118 #endif
119 
122 #ifndef D4D_COLOR_SLDR_BAR_BCKG
123  #define D4D_COLOR_SLDR_BAR_BCKG D4D_COLOR_BRIGHT_GREY
124 #endif
125 
128 #ifndef D4D_COLOR_SLDR_BAR_START
129  #define D4D_COLOR_SLDR_BAR_START D4D_COLOR_GREEN
130 #endif
131 
134 #ifndef D4D_COLOR_SLDR_BAR_END
135  #define D4D_COLOR_SLDR_BAR_END D4D_COLOR_RED
136 #endif
137 
140 /******************************************************************************
141 * D4D SLIDER setting public types
142 *
143 */
149 
151 typedef struct
152 {
158 
159 /**************************************************************************/
166 typedef void (*D4D_SLDR_ON_CHANGE)(D4D_OBJECT* pThis);
167 
169 /******************************************************************************
170 * Private Types
171 ******************************************************************************/
172 
173 // slider runtime data (always in RAM)
174 typedef struct
175 {
176  D4D_SLIDER_VALUE value; // current value
177  D4D_SLIDER_LIMITS limits; // slider runtime configuration
178  D4D_COLOR colorBar; // Color v Bar - can be changed
180 
181 // slider configuration (in ROM by default)
182 
183 typedef struct
184 {
185  D4D_STRING textBuff; // slider text
186  D4D_POINT txtOff; // text coordinates as offset from scrPos
187  D4D_POINT barOff; // hub coordinates as offset from scrPos
188  D4D_SIZE barSize; // value bar size (if cx>cy, then bar is horizontal, otherwise vertical)
189  const D4D_BMP* pBmpBkgd; // slider background bitmap
190  D4D_SLDR_ON_CHANGE OnValueChanged; // pointer to on change call back function
192 } D4D_SLIDER;
193 
194 
195 /******************************************************************************
196 * Macros
197 ******************************************************************************/
198 
199 // getting the SLIDER structure from general OBJECT
200 #define D4D_GET_SLIDER(pObj) ((D4D_SLIDER*)((pObj)->pParam))
201 
202 /******************************************************************************
203 * D4D SLIDER setting public macros
204 *
205 */
209 /**************************************************************************/
239 #define _D4D_DECLARE_SLIDER(type, name, text, x, y, cx, cy, radius, pMargin, pRelations, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
240  static D4D_SLIDER_DATA name##_data = { 0, 0, 100, 1, 0, D4D_COLOR_SLDR_BAR_FORE}; \
241  static D4D_STR_PROPERTIES name##_strPrties = { D4D_SLDR_FNT_PRTY_DEFAULT, D4D_SLDR_TXT_PRTY_DEFAULT}; \
242  static type D4D_SLIDER name##_params = \
243  { \
244  { text, D4D_TEXT_LEN(text), fontId, &name##_strPrties, D4D_OBJECT_MAX_TEXT_LEN(text), 0}, /* textBuff */ \
245  { tx, ty }, /* txtOff */ \
246  { bx, by }, /* barOff */ \
247  { bcx, bcy }, /* barSize */ \
248  pBmp, /* pBmpBkgd */ \
249  onvalch, /* OnValueCanged */ \
250  &(name##_data) /* RAM-based data */ \
251  }; \
252  \
253  D4D_DECLARE_OBJECT(type, name, x, y, cx, cy, radius, pMargin, pRelations, pOnUsrMsg, &d4d_sliderSysFunc, &(name##_params), flags, pUser, pScheme)
254 
255 
256 /**************************************************************************/
283 #define D4D_DECLARE_SLIDER(name, text, x, y, cx, cy, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
284  _D4D_DECLARE_SLIDER(D4D_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
285 
286 /**************************************************************************/
309 #define D4D_DECLARE_STD_SLIDER(name, text, x, y, cx, cy, tx, ty, bx, by, bcx, bcy, pBmp, fontId, onvalch) \
310  D4D_DECLARE_SLIDER(name, text, x, y, cx, cy, tx, ty, bx, by, bcx, bcy, (D4D_SLDR_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
311 
312 /**************************************************************************/
334 #define D4D_DECLARE_SLIDER_AUTOSIZE(name, text, x, y, cx, cy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
335  D4D_DECLARE_SLIDER(name, text, x, y, cx, cy, 0, 0, 0, 0, 0, 0, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
336 
337 /**************************************************************************/
355 #define D4D_DECLARE_STD_SLIDER_AUTOSIZE(name, text, x, y, cx, cy, pBmp, fontId, onvalch) \
356  D4D_DECLARE_STD_SLIDER(name, text, x, y, cx, cy, 0, 0, 0, 0, 0, 0, pBmp, fontId, onvalch)
357 
358 
359 /**************************************************************************/
387 #define D4D_DECLARE_RSLIDER(name, text, x, y, cx, cy, radius, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
388  _D4D_DECLARE_SLIDER(D4D_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
389 
390 /**************************************************************************/
414 #define D4D_DECLARE_STD_RSLIDER(name, text, x, y, cx, cy, radius, tx, ty, bx, by, bcx, bcy, pBmp, fontId, onvalch) \
415  D4D_DECLARE_RSLIDER(name, text, x, y, cx, cy, radius, tx, ty, bx, by, bcx, bcy, (D4D_SLDR_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
416 
417 /**************************************************************************/
440 #define D4D_DECLARE_RSLIDER_AUTOSIZE(name, text, x, y, cx, cy, radius, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
441  D4D_DECLARE_RSLIDER(name, text, x, y, cx, cy, radius, 0, 0, 0, 0, 0, 0, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
442 
443 /**************************************************************************/
462 #define D4D_DECLARE_STD_RSLIDER_AUTOSIZE(name, text, x, y, cx, cy, radius, pBmp, fontId, onvalch) \
463  D4D_DECLARE_STD_RSLIDER(name, text, x, y, cx, cy, radius, 0, 0, 0, 0, 0, 0, pBmp, fontId, onvalch)
464 
465 
466 // IN RAM instantions macros
467 /**************************************************************************/
470 #define D4D_DECLARE_SLIDER_INRAM(name, text, x, y, cx, cy, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
471  _D4D_DECLARE_SLIDER( D4D_NO_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
472 
473 /**************************************************************************/
476 #define D4D_DECLARE_STD_SLIDER_INRAM(name, text, x, y, cx, cy, tx, ty, bx, by, bcx, bcy, pBmp, fontId, onvalch) \
477  D4D_DECLARE_SLIDER_INRAM(name, text, x, y, cx, cy, tx, ty, bx, by, bcx, bcy, (D4D_SLDR_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
478 
479 /**************************************************************************/
482 #define D4D_DECLARE_SLIDER_AUTOSIZE_INRAM(name, text, x, y, cx, cy, flags, pBmp, pScheme, font, pUser, onvalch, pOnUsrMsg) \
483  D4D_DECLARE_SLIDER_INRAM(name, text, x, y, cx, cy, 0, 0, 0, 0, 0, 0, flags, pBmp, pScheme, font, pUser, onvalch, pOnUsrMsg)
484 
485 /**************************************************************************/
488 #define D4D_DECLARE_STD_SLIDER_AUTOSIZE_INRAM(name, text, x, y, cx, cy, pBmp, font, onvalch) \
489  D4D_DECLARE_STD_SLIDER_INRAM(name, text, x, y, cx, cy, 0, 0, 0, 0, 0, 0, pBmp, font, onvalch)
490 
491 // Rounded slider definition
492 /**************************************************************************/
495 #define D4D_DECLARE_RSLIDER_INRAM(name, text, x, y, cx, cy, radius, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
496  _D4D_DECLARE_SLIDER(D4D_NO_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, tx, ty, bx, by, bcx, bcy, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
497 
498 /**************************************************************************/
501 #define D4D_DECLARE_STD_RSLIDER_INRAM(name, text, x, y, cx, cy, radius, tx, ty, bx, by, bcx, bcy, pBmp, fontId, onvalch) \
502  D4D_DECLARE_RSLIDER_INRAM(name, text, x, y, cx, cy, radius, tx, ty, bx, by, bcx, bcy, (D4D_SLDR_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
503 
504 /**************************************************************************/
507 #define D4D_DECLARE_RSLIDER_AUTOSIZE_INRAM(name, text, x, y, cx, cy, radius, flags, pBmp, pScheme, font, pUser, onvalch, pOnUsrMsg) \
508  D4D_DECLARE_RSLIDER_INRAM(name, text, x, y, cx, cy, radius, 0, 0, 0, 0, 0, 0, flags, pBmp, pScheme, font, pUser, onvalch, pOnUsrMsg)
509 
510 /**************************************************************************/
513 #define D4D_DECLARE_STD_RSLIDER_AUTOSIZE_INRAM(name, text, x, y, cx, cy, radius, pBmp, font, onvalch) \
514  D4D_DECLARE_STD_RSLIDER_INRAM(name, text, x, y, cx, cy, radius, 0, 0, 0, 0, 0, 0, pBmp, font, onvalch)
515 
518 /******************************************************************************
519 * Global functions
520 ******************************************************************************/
521 
522 /*********************************************************
523 *
524 * global functions
525 *
526 *********************************************************/
527 
531 
532 void D4D_SldrSetLimits(D4D_OBJECT_PTR pThis, const D4D_SLIDER_LIMITS* pLimits);
534 
535 void D4D_SldrSetBarColor(D4D_OBJECT_PTR pThis, D4D_COLOR color);
537 
538 
539 // Obsolete functions, replaced by any general
540 #define D4D_SldrSetText D4D_SetText
541 
542 
543 #endif /* __D4D_SLIDER_H */
544 
545 
546 
547 
548 
549 
550 
551 
552 
553 
554 
const D4D_BMP * pBmpBkgd
Definition: d4d_slider.h:189
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
D4D_SLIDER_VALUE valueOrg
bar origin value (should be valueMin &lt;= org &lt;= valueMax)
Definition: d4d_slider.h:156
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
D4D_SLIDER_VALUE value
Definition: d4d_slider.h:176
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
void D4D_SldrSetBarColor(D4D_OBJECT_PTR pThis, D4D_COLOR color)
Function Sets the slider bar color.
Definition: d4d_slider.c:538
D4D_SLIDER_VALUE valueMax
maximal value - &lt;valueMin..127&gt;
Definition: d4d_slider.h:154
D4D_COLOR colorBar
Definition: d4d_slider.h:178
void D4D_SldrGetLimits(D4D_OBJECT_PTR pThis, D4D_SLIDER_LIMITS *pLimits)
Function get the current limits of slider object.
Definition: d4d_slider.c:606
D4D_SLIDER_VALUE step
step value of slider change
Definition: d4d_slider.h:155
D4D_SIZE barSize
Definition: d4d_slider.h:188
D4D_POINT txtOff
Definition: d4d_slider.h:186
D4D_BMP eGUI main image structure.
Definition: d4d_bmp.h:100
D4D_COLOR D4D_SldrGetBarColor(D4D_OBJECT_PTR pThis)
Definition: d4d_slider.c:555
Type definition of slider limits structure.
Definition: d4d_slider.h:151
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
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
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_SLIDER_LIMITS limits
Definition: d4d_slider.h:177
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
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
D4D_POINT barOff
Definition: d4d_slider.h:187
void(* D4D_SLDR_ON_CHANGE)(D4D_OBJECT *pThis)
Type definition of slider on change callback function.
Definition: d4d_slider.h:166