eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_list_box.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_LIST_BOX_H
47 #define __D4D_LIST_BOX_H
48 
50 void D4D_ListBoxScrollBarsFeedBack(D4D_OBJECT* pThis, D4D_INDEX old_position, D4D_INDEX new_position);
51 /******************************************************************************
52 * D4D LIST BOX setting constants
53 *
54 */
58 //********************* List Box flags for button specific flags *****************
69 #define D4D_LIST_BOX_F_SIDEBAR (0x01 << D4D_OBJECT_F_OBJECT_SHIFT)
70 
74 #ifndef D4D_LIST_BOX_F_DEFAULT
75  #define D4D_LIST_BOX_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_DENTED)
76 #endif
77 
80 #ifndef D4D_LIST_BOX_F_SCRLBRS_DEFAULT
81  #define D4D_LIST_BOX_F_SCRLBRS_DEFAULT (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_TOUCHENABLE | D4D_OBJECT_F_FASTTOUCH | D4D_OBJECT_F_BEVEL_RAISED | D4D_OBJECT_F_MOUSE_NORMAL)
82 #endif
83 
86 #ifndef D4D_LIST_BOX_SCRLBR_WIDTH
87  #define D4D_LIST_BOX_SCRLBR_WIDTH ( 20 )
88 #endif
89 
92 #ifndef D4D_LIST_BOX_SCRLBR_STEP
93  #define D4D_LIST_BOX_SCRLBR_STEP ( 1 )
94 #endif
95 
98 #ifndef D4D_LIST_BOX_ITEM_TXT_PRTY_DEFAULT
99  #define D4D_LIST_BOX_ITEM_TXT_PRTY_DEFAULT ( D4D_ALIGN_V_CENTER_MASK | D4D_ALIGN_H_LEFT_MASK )
100 #endif
101 
104 #ifndef D4D_LIST_BOX_ITEM_FNT_PRTY_DEFAULT
105  #define D4D_LIST_BOX_ITEM_FNT_PRTY_DEFAULT ( 0 )
106 #endif
107 
110 /******************************************************************************
111 * D4D LIST BOX setting public types
112 *
113 */
117 /**************************************************************************/
125 typedef void (*D4D_LSTBX_ON_EVENT)(D4D_OBJECT* pThis, D4D_EVENTID eventId);
126 
129 
131 typedef struct
132 {
134  void* pUser;
136 
139 /******************************************************************************
140 * Private Types
141 ******************************************************************************/
142 
143 typedef struct
144 {
149 
150 typedef struct
151 {
153  D4D_LIST_BOX_INDEX posCnt; // Number of visiable position
154  D4D_COOR textOff; // text offset between individual item on screen
155  D4D_LIST_BOX_DATA* pData; // ListBox volatile data struct
157 } D4D_LIST_BOX;
158 
159 
160 #define D4D_LIST_BOX_CHILD_SCROLL_BAR_IX 1
161 
162 /******************************************************************************
163 * Macros
164 ******************************************************************************/
165 
166 // getting the LIST_BOX structure from general OBJECT
167 #define D4D_GET_LIST_BOX(pObj) ((D4D_LIST_BOX*)((pObj)->pParam))
168 
169 #define D4D_GET_LIST_BOX_SCROLL_BAR(pObj) ((D4D_OBJECT*)((pObj)->pRelations[D4D_LIST_BOX_CHILD_SCROLL_BAR_IX]))
170 
171 /******************************************************************************
172 * D4D LIST BOX setting public macros
173 *
174 */
178 /**************************************************************************/
203 #define _D4D_DECLARE_LIST_BOX_BEGIN(type, name, x, y, cx, cy, radius, pMargin, pParent, flags, pScheme,\
204  itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg) \
205  extern type D4D_LIST_BOX_ITEM name##_items[];\
206  extern type D4D_OBJECT name##_scrollBarVer;\
207  static D4D_LIST_BOX_DATA name##_data = { 0, 0, (const D4D_LIST_BOX_ITEM*)&(name##_items[0])};\
208  static const D4D_OBJECT * const name##_relations[] = {pParent, &name##_scrollBarVer, NULL};\
209  static type D4D_LIST_BOX name##_params = \
210  { \
211  itemsFontId, \
212  posCnt, \
213  listBoxItemsOff, \
214  &(name##_data), \
215  pOnEvent \
216  }; \
217  \
218  D4D_DECLARE_OBJECT(type, name, x, y, cx, cy, radius, pMargin, name##_relations, pOnUsrMsg, &d4d_listBoxSysFunc, &(name##_params), flags, pUser, pScheme)\
219  \
220  static const D4D_OBJECT* const name##_scrollBarVerRelations[] = {&name, NULL};\
221  _D4D_DECLARE_SCROLL_BAR(type, name##_scrollBarVer, (D4D_COOR)(cx - D4D_LIST_BOX_SCRLBR_WIDTH - 2*D4D_BEVEL_WIDTH), 0, D4D_LIST_BOX_SCRLBR_WIDTH, (D4D_COOR)(cy - 2*D4D_BEVEL_WIDTH),\
222  radius, NULL, name##_scrollBarVerRelations, D4D_LIST_BOX_F_SCRLBRS_DEFAULT, pScheme, (void*)&name, D4D_ListBoxScrollBarsFeedBack, NULL) \
223  \
224  type D4D_LIST_BOX_ITEM name##_items[] = { \
225 
226 
227 /**************************************************************************/
240 #define D4D_DECLARE_LIST_BOX_ITEM(pText, pUser) { pText, (void*)pUser},
241 
242 /**************************************************************************/
253 #define D4D_DECLARE_LIST_BOX_END() { NULL, NULL} };
254 
255 /**************************************************************************/
278 #define D4D_DECLARE_LIST_BOX_BEGIN(name, x, y, cx, cy, flags, pParent, pScheme, itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg) \
279  _D4D_DECLARE_LIST_BOX_BEGIN(D4D_CONST, name, x, y, cx, cy, 0, (D4D_MARGIN*)&listBox_marginDefault, pParent, flags, pScheme,\
280  itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg)
281 
282 /**************************************************************************/
299 #define D4D_DECLARE_STD_LIST_BOX_BEGIN(name, x, y, cx, cy, pParent, itemsFontId, pOnEvent) \
300  D4D_DECLARE_LIST_BOX_BEGIN(name, x, y, cx, cy, (D4D_LIST_BOX_F_DEFAULT), pParent, NULL, itemsFontId, 0, 0, NULL, pOnEvent, NULL)
301 
302 // Rounded listBox definition
303 /**************************************************************************/
327 #define D4D_DECLARE_RLIST_BOX_BEGIN(name, x, y, cx, cy, radius, flags, pParent, pScheme, itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg) \
328  _D4D_DECLARE_LIST_BOX_BEGIN(D4D_CONST, name, x, y, cx, cy, radius, (D4D_MARGIN*)&listBox_marginDefault, pParent, flags, pScheme,\
329  itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg)
330 
331 /**************************************************************************/
349 #define D4D_DECLARE_STD_RLIST_BOX_BEGIN(name, x, y, cx, cy, radius, pParent, itemsFontId, pOnEvent) \
350  D4D_DECLARE_RLIST_BOX_BEGIN(name, x, y, cx, cy, radius, (D4D_LIST_BOX_F_DEFAULT), pParent, NULL, itemsFontId, 0, 0, NULL, pOnEvent, NULL)
351 
352 
353 //IN RAM instantions macros
354 /**************************************************************************/
357 #define D4D_DECLARE_LIST_BOX_BEGIN_INRAM(name, x, y, cx, cy, flags, pParent, pScheme, itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg) \
358  _D4D_DECLARE_LIST_BOX_BEGIN(D4D_NO_CONST, name, x, y, cx, cy, 0, (D4D_MARGIN*)&listBox_marginDefault, pParent, flags, pScheme,\
359  itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg)
360 
361 /**************************************************************************/
364 #define D4D_DECLARE_STD_LIST_BOX_BEGIN_INRAM(name, x, y, cx, cy, pParent, itemsFontId, pOnEvent) \
365  D4D_DECLARE_LIST_BOX_BEGIN_INRAM(name, x, y, cx, cy, (D4D_LIST_BOX_F_DEFAULT), pParent, NULL, itemsFontId, 0, 0, NULL, pOnEvent, NULL)
366 
367 
368 // Rounded listBox definition
369 /**************************************************************************/
372 #define D4D_DECLARE_RLIST_BOX_BEGIN_INRAM(name, x, y, cx, cy, radius, flags, pParent, pScheme, itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg) \
373  _D4D_DECLARE_LIST_BOX_BEGIN(D4D_NO_CONST, name, x, y, cx, cy, radius, (D4D_MARGIN*)&listBox_marginDefault, pParent, flags, pScheme,\
374  itemsFontId, posCnt, listBoxItemsOff, pUser, pOnEvent, pOnUsrMsg)
375 
376 /**************************************************************************/
379 #define D4D_DECLARE_STD_RLIST_BOX_BEGIN_INRAM(name, x, y, cx, cy, radius, pParent, itemsFontId, pOnEvent) \
380  D4D_DECLARE_RLIST_BOX_BEGIN_INRAM(name, x, y, cx, cy, radius, (D4D_LIST_BOX_F_DEFAULT), pParent, NULL, itemsFontId, 0, 0, NULL, pOnEvent, NULL)
381 
384 /******************************************************************************
385 * Global variables
386 ******************************************************************************/
387 extern const D4D_MARGIN listBox_marginDefault;
388 
389 /******************************************************************************
390 * Global functions
391 ******************************************************************************/
393 
401 
404 #endif /* __D4D_LIST_BOX_H */
405 
406 
407 
408 
D4D_WCHAR D4D_TCHAR
Type definition of eGUI character (it depends on UNICODE setting if this is D4D_CHAR or D4D_WCHAR)...
Definition: d4d_types.h:284
Byte D4D_FONT
Definition: d4d_font.h:171
D4D_LIST_BOX_ITEM * D4D_ListBoxGetItemList(D4D_OBJECT_PTR pThis)
Function gets the current using item list.
Definition: d4d_list_box.c:655
void D4D_ListBoxChangeItemList(D4D_OBJECT_PTR pThis, const D4D_LIST_BOX_ITEM *pItems)
Function change the items list using by list box.
Definition: d4d_list_box.c:637
const D4D_MARGIN listBox_marginDefault
Definition: d4d_list_box.c:64
D4D_LIST_BOX_INDEX D4D_ListBoxGetItemCount(D4D_OBJECT_PTR pThis)
Function gets the count of list box items.
Definition: d4d_list_box.c:560
This is list box item variable type.
Definition: d4d_list_box.h:131
D4D_TCHAR * pText
pointer to item text
Definition: d4d_list_box.h:133
const D4D_OBJECT_SYS_FUNCTION d4d_listBoxSysFunc
Definition: d4d_list_box.c:56
D4D_COOR textOff
Definition: d4d_list_box.h:154
D4D_FONT itemsFontId
Definition: d4d_list_box.h:152
D4D_LIST_BOX_DATA * pData
Definition: d4d_list_box.h:155
D4D_LIST_BOX_INDEX D4D_ListBoxGetIndex(D4D_OBJECT *pThis)
Function returns the current selected item index.
Definition: d4d_list_box.c:516
D4D_TCHAR * D4D_ListBoxGetItemTextIx(D4D_OBJECT_PTR pThis, D4D_LIST_BOX_INDEX ix)
Function gets the text of item choosed by item index.
Definition: d4d_list_box.c:620
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
D4D_LIST_BOX_INDEX D4D_ListBoxFindUserDataItem(D4D_OBJECT_PTR pThis, void *pUser)
Function finds the index of items with specified user data.
Definition: d4d_list_box.c:574
void D4D_ListBoxScrollBarsFeedBack(D4D_OBJECT *pThis, D4D_INDEX old_position, D4D_INDEX new_position)
Definition: d4d_list_box.c:472
void D4D_ListBoxSetIndex(D4D_OBJECT *pThis, D4D_LIST_BOX_INDEX ix)
Function select new item by index.
Definition: d4d_list_box.c:533
sByte D4D_LIST_BOX_INDEX
This is list box item index variable type.
Definition: d4d_list_box.h:128
D4D_EVENTID
D4D events that is handled by object callback functions.
Definition: d4d_base.h:429
void D4D_ListBoxEnsureVisible(D4D_OBJECT *pThis)
Function ensure that the selected item in list will be scrolled to visible area.
Definition: d4d_list_box.c:494
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
signed char sByte
Type definition of sByte (signed 8-bit).
Definition: d4d_types.h:155
D4D_TCHAR * D4D_ListBoxGetItemText(D4D_OBJECT_PTR pThis)
Function gets the selected item text.
Definition: d4d_list_box.c:607
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
D4D_LIST_BOX_INDEX page_ix
Definition: d4d_list_box.h:146
D4D_LSTBX_ON_EVENT OnEvent
Definition: d4d_list_box.h:156
D4D_LIST_BOX_INDEX posCnt
Definition: d4d_list_box.h:153
void * D4D_ListBoxGetItemUserData(D4D_OBJECT_PTR pThis)
Function gets the selected item user data.
Definition: d4d_list_box.c:595
const D4D_LIST_BOX_ITEM * pItems
Definition: d4d_list_box.h:147
D4D_LIST_BOX_INDEX ix
Definition: d4d_list_box.h:145
void * pUser
pointer to void (it can be retype to any other user data in size or less that is pointer size) ...
Definition: d4d_list_box.h:134
void(* D4D_LSTBX_ON_EVENT)(D4D_OBJECT *pThis, D4D_EVENTID eventId)
Type definition of list box on event callback function.
Definition: d4d_list_box.h:125
Type definition of eGUI client area margin structure.
Definition: d4d_types.h:244