eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_button.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_BUTTON_H
47 #define __D4D_BUTTON_H
48 
50 
51 /******************************************************************************
52 * D4D BUTTON setting constants
53 *
54 */
60 #ifndef D4D_BTN_3D_SHIFT
61  #define D4D_BTN_3D_SHIFT 1
62 #endif
63 
64 //********************* Button flags for button specific flags *****************
75  #define D4D_BTN_F_3D (0x01 << D4D_OBJECT_F_OBJECT_SHIFT)
76  #define D4D_BTN_F_CONT_RECT (0x02 << D4D_OBJECT_F_OBJECT_SHIFT)
77  #define D4D_BTN_F_INVERT (0x04 << D4D_OBJECT_F_OBJECT_SHIFT)
78 
80 //******************************************************************************
81 
82 // button configuration (goes to ROM by default)
83 
86 #ifndef D4D_BTN_F_DEFAULT
87  #define D4D_BTN_F_DEFAULT (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_TOUCHENABLE | D4D_OBJECT_F_MOUSE_NORMAL | D4D_OBJECT_F_BEVEL_RAISED | D4D_BTN_F_3D)
88 #endif
89 
92 #ifndef D4D_BTN_TXT_PRTY_DEFAULT
93  #define D4D_BTN_TXT_PRTY_DEFAULT (D4D_ALIGN_H_CENTER_MASK | D4D_ALIGN_V_CENTER_MASK)
94 #endif
95 
98 #ifndef D4D_BTN_FNT_PRTY_DEFAULT
99  #define D4D_BTN_FNT_PRTY_DEFAULT ( 0 )
100 #endif
101 
104 #ifndef D4D_BUTTON_3D_FORE_INTENSITY
105  #define D4D_BUTTON_3D_FORE_INTENSITY D4D_BEVEL_FORE_INTENSITY
106 #endif
107 
110 #ifndef D4D_BUTTON_3D_BCKG_INTENSITY
111  #define D4D_BUTTON_3D_BCKG_INTENSITY D4D_BEVEL_BCKG_INTENSITY
112 #endif
113 
118 /******************************************************************************
119 * D4D BUTTON setting public types
120 *
121 */
125 /**************************************************************************/
132 typedef void (*D4D_BTN_ON_CLICK)(D4D_OBJECT* pThis);
133 
136 /******************************************************************************
137 * Private Types
138 ******************************************************************************/
139 
141 
142 #define D4D_BUTTON_STATUS_PRESSED_MASK (0x01)
143 #define D4D_BUTTON_STATUS_1ST_TOUCH_MASK (0x02)
144 #define D4D_BUTTON_STATUS_MOUSE_CLICK_MASK (0x04)
145 
146 
147 typedef struct
148 {
149  D4D_STRING textBuff; // button text
150  const D4D_BMP* pBmpNormal; // normal state bitmap
151  const D4D_BMP* pBmpFocus; // focused state bitmap
154 } D4D_BUTTON;
155 
156 
157 /******************************************************************************
158 * Macros
159 ******************************************************************************/
160 
161 // getting the BUTTON structure from general OBJECT
162 #define D4D_GET_BUTTON(pObj) ((D4D_BUTTON*)((pObj)->pParam))
163 #define D4D_GET_BUTTON_STATUS(pObj) ((D4D_BUTTON_STATUS*)(D4D_GET_BUTTON(pObj)->pStatus))
164 
165 
166 /******************************************************************************
167 * D4D BUTTON setting public macros
168 *
169 */
173 /**************************************************************************/
198 #define _D4D_DECLARE_BUTTON(type, name, text, x, y, cx, cy, radius, pMargin, pRelations, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg) \
199  static D4D_BUTTON_STATUS name##_status = { 0 }; \
200  static D4D_STR_PROPERTIES name##_strPrties = { D4D_BTN_FNT_PRTY_DEFAULT, D4D_BTN_TXT_PRTY_DEFAULT}; \
201  static type D4D_BUTTON name##_params = \
202  { \
203  { text, D4D_TEXT_LEN(text), fontId, &name##_strPrties, D4D_OBJECT_MAX_TEXT_LEN(text), 0}, /* textBuff */ \
204  pBmpN, /* pBmpNormal */ \
205  pBmpF, /* pBmpFocus */ \
206  &(name##_status), /* Status clear */ \
207  onclick /* Click event */ \
208  }; \
209  \
210  D4D_DECLARE_OBJECT(type, name, x, y, cx, cy, radius, pMargin, pRelations, pOnUsrMsg, &d4d_btnSysFunc, &(name##_params), flags, pUser, pScheme)
211 
212 /**************************************************************************/
234 #define D4D_DECLARE_BUTTON(name, text, x, y, cx, cy, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg) \
235  _D4D_DECLARE_BUTTON(D4D_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg)
236 
237 /**************************************************************************/
255 #define D4D_DECLARE_STD_BUTTON(name, text, x, y, cx, cy, pBmpN, pBmpF, fontId, onclick) \
256  D4D_DECLARE_BUTTON(name, text, x, y, cx, cy, (D4D_BTN_F_DEFAULT), pBmpN, pBmpF, NULL, fontId, NULL, onclick, NULL)
257 
258 /**************************************************************************/
274 #define D4D_DECLARE_TXT_BUTTON(name, text, x, y, cx, cy, fontId, onclick) \
275  D4D_DECLARE_STD_BUTTON(name, text, x, y, cx, cy, NULL, NULL, \
276  fontId, onclick)
277 
278 
279 // Rounded button definition
280 /**************************************************************************/
303 #define D4D_DECLARE_RBUTTON(name, text, x, y, cx, cy, radius, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg) \
304  _D4D_DECLARE_BUTTON(D4D_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg)
305 
306 /**************************************************************************/
325 #define D4D_DECLARE_STD_RBUTTON(name, text, x, y, cx, cy, radius, pBmpN, pBmpF, fontId, onclick) \
326  D4D_DECLARE_RBUTTON(name, text, x, y, cx, cy, radius, (D4D_BTN_F_DEFAULT), pBmpN, pBmpF, NULL, fontId, NULL, onclick, NULL)
327 
328 /**************************************************************************/
345 #define D4D_DECLARE_TXT_RBUTTON(name, text, x, y, cx, cy, radius, fontId, onclick) \
346  D4D_DECLARE_STD_RBUTTON(name, text, x, y, cx, cy, radius, NULL, NULL, \
347  fontId, onclick)
348 
349 // IN RAM instantion macros
350 /**************************************************************************/
353 #define D4D_DECLARE_BUTTON_INRAM(name, text, x, y, cx, cy, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg) \
354  _D4D_DECLARE_BUTTON(D4D_NO_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg)
355 
356 /**************************************************************************/
359 #define D4D_DECLARE_STD_BUTTON_INRAM(name, text, x, y, cx, cy, bmpN, bmpF, fontId, onclick) \
360  D4D_DECLARE_BUTTON_INRAM(name, text, x, y, cx, cy, (D4D_BTN_F_DEFAULT), bmpN, bmpF, NULL, fontId, NULL, onclick, NULL)
361 
362 /**************************************************************************/
365 #define D4D_DECLARE_TXT_BUTTON_INRAM(name, text, x, y, cx, cy, fontId, onclick) \
366  D4D_DECLARE_STD_BUTTON_INRAM(name, text, x, y, cx, cy, NULL, NULL, \
367  fontId, onclick)
368 
369 // Rounded button definition
370 /**************************************************************************/
373 #define D4D_DECLARE_RBUTTON_INRAM(name, text, x, y, cx, cy, radius, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg) \
374  _D4D_DECLARE_BUTTON(D4D_NO_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, flags, pBmpN, pBmpF, pScheme, fontId, pUser, onclick, pOnUsrMsg)
375 
376 /**************************************************************************/
379 #define D4D_DECLARE_STD_RBUTTON_INRAM(name, text, x, y, cx, cy, radius, bmpN, bmpF, fontId, onclick) \
380  D4D_DECLARE_RBUTTON_INRAM(name, text, x, y, cx, cy, radius, (D4D_BTN_F_DEFAULT), bmpN, bmpF, NULL, fontId, NULL, onclick, NULL)
381 
382 /**************************************************************************/
385 #define D4D_DECLARE_TXT_RBUTTON_INRAM(name, text, x, y, cx, cy, radius, fontId, onclick) \
386  D4D_DECLARE_STD_RBUTTON_INRAM(name, text, x, y, cx, cy, radius, NULL, NULL, \
387  fontId, onclick)
388 
390 /******************************************************************************
391 * Global functions
392 ******************************************************************************/
393 
394 /*********************************************************
395 *
396 * Object API
397 *
398 *********************************************************/
399 
400 // Obsolete functions, replaced by any general
401 #define D4D_BtnSetText D4D_SetText
402 
403 #endif /*__D4D_BUTTON_H*/
404 
405 
406 
407 
408 
409 
410 
411 
412 
413 
414 
415 
D4D_BUTTON_STATUS * pStatus
Definition: d4d_button.h:152
const D4D_BMP * pBmpNormal
Definition: d4d_button.h:150
D4D_BTN_ON_CLICK OnClicked
Definition: d4d_button.h:153
const D4D_BMP * pBmpFocus
Definition: d4d_button.h:151
The string type. This structure contains all properties about string in eGUI.
Definition: d4d_string.h:100
D4D_STRING textBuff
Definition: d4d_button.h:149
Byte D4D_BUTTON_STATUS
Definition: d4d_button.h:140
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
void(* D4D_BTN_ON_CLICK)(D4D_OBJECT *pThis)
Type definition of button on click callback function.
Definition: d4d_button.h:132
D4D_BMP eGUI main image structure.
Definition: d4d_bmp.h:100
The object main structure type definition.
Definition: d4d_object.h:167
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
const D4D_OBJECT_SYS_FUNCTION d4d_btnSysFunc
Definition: d4d_button.c:53