2014-03-28 19:33:20 +00:00
|
|
|
/**
|
|
|
|
* @file bemenu.h
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* Public API header.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
typedef struct _bmMenu bmMenu;
|
|
|
|
typedef struct _bmItem bmItem;
|
|
|
|
|
2014-04-12 21:12:31 +00:00
|
|
|
/**
|
|
|
|
* @defgroup Library
|
|
|
|
* @brief Library functions.
|
|
|
|
*
|
|
|
|
* Query library version, etc...
|
|
|
|
*/
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/**
|
|
|
|
* @defgroup Menu
|
|
|
|
* @brief Menu container.
|
|
|
|
*
|
|
|
|
* Holds all the items, runs logic and gets rendered.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Item
|
|
|
|
* @brief Item container.
|
|
|
|
*
|
|
|
|
* Contains properties for visual representation of item.
|
|
|
|
*/
|
|
|
|
|
2014-04-12 19:12:44 +00:00
|
|
|
/**
|
2014-04-12 21:12:31 +00:00
|
|
|
* @addtogroup Library
|
2014-04-12 19:12:44 +00:00
|
|
|
* @{ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Library Version
|
|
|
|
* @{ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get version of the library in 'major.minor.patch' format.
|
|
|
|
*
|
|
|
|
* @see @link http://semver.org/ Semantic Versioning @endlink
|
|
|
|
*
|
|
|
|
* @return Null terminated C "string" to version string.
|
|
|
|
*/
|
|
|
|
const char* bmVersion(void);
|
|
|
|
|
|
|
|
/** @} Library Version */
|
|
|
|
|
|
|
|
/** @} Library */
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup Menu
|
|
|
|
* @{ */
|
|
|
|
|
2014-03-28 19:33:20 +00:00
|
|
|
/**
|
2014-04-09 22:09:35 +00:00
|
|
|
* Draw mode constants for bmMenu instance draw mode.
|
2014-03-28 19:59:34 +00:00
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* @link ::bmDrawMode BM_DRAW_MODE_LAST @endlink is provided for enumerating draw modes.
|
2014-03-28 19:59:34 +00:00
|
|
|
* Instancing with it however provides exactly same functionality as BM_DRAW_MODE_NONE.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
|
|
|
typedef enum bmDrawMode {
|
2014-03-28 19:59:34 +00:00
|
|
|
BM_DRAW_MODE_NONE,
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_DRAW_MODE_CURSES,
|
2014-03-28 19:59:34 +00:00
|
|
|
BM_DRAW_MODE_LAST
|
2014-03-28 19:33:20 +00:00
|
|
|
} bmDrawMode;
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Filter mode constants for bmMenu instance filter mode.
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* @link ::bmFilterMode BM_FILTER_MODE_LAST @endlink is provided for enumerating filter modes.
|
2014-04-09 22:09:35 +00:00
|
|
|
* Using it as filter mode however provides exactly same functionality as BM_FILTER_MODE_DMENU.
|
|
|
|
*/
|
|
|
|
typedef enum bmFilterMode {
|
|
|
|
BM_FILTER_MODE_DMENU,
|
|
|
|
BM_FILTER_MODE_DMENU_CASE_INSENSITIVE,
|
|
|
|
BM_FILTER_MODE_LAST
|
|
|
|
} bmFilterMode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Result constants from bmMenuRunWithKey function.
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* - @link ::bmRunResult BM_RUN_RESULT_RUNNING @endlink means that menu is running and thus should be still renderer && ran.
|
|
|
|
* - @link ::bmRunResult BM_RUN_RESULT_SELECTED @endlink means that menu was closed and items were selected.
|
|
|
|
* - @link ::bmRunResult BM_RUN_RESULT_CANCEL @endlink means that menu was closed and selection was canceled.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
|
|
|
typedef enum bmRunResult {
|
|
|
|
BM_RUN_RESULT_RUNNING,
|
|
|
|
BM_RUN_RESULT_SELECTED,
|
|
|
|
BM_RUN_RESULT_CANCEL,
|
|
|
|
} bmRunResult;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Key constants.
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* @link ::bmKey BM_KEY_LAST @endlink is provided for enumerating keys.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
|
|
|
typedef enum bmKey {
|
|
|
|
BM_KEY_NONE,
|
|
|
|
BM_KEY_UP,
|
|
|
|
BM_KEY_DOWN,
|
|
|
|
BM_KEY_LEFT,
|
|
|
|
BM_KEY_RIGHT,
|
|
|
|
BM_KEY_HOME,
|
|
|
|
BM_KEY_END,
|
|
|
|
BM_KEY_PAGE_UP,
|
|
|
|
BM_KEY_PAGE_DOWN,
|
2014-04-12 15:42:30 +00:00
|
|
|
BM_KEY_SHIFT_PAGE_UP,
|
|
|
|
BM_KEY_SHIFT_PAGE_DOWN,
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_KEY_BACKSPACE,
|
|
|
|
BM_KEY_DELETE,
|
|
|
|
BM_KEY_LINE_DELETE_LEFT,
|
|
|
|
BM_KEY_LINE_DELETE_RIGHT,
|
|
|
|
BM_KEY_WORD_DELETE,
|
|
|
|
BM_KEY_TAB,
|
|
|
|
BM_KEY_ESCAPE,
|
|
|
|
BM_KEY_RETURN,
|
2014-04-10 17:04:06 +00:00
|
|
|
BM_KEY_SHIFT_RETURN,
|
2014-04-12 15:44:03 +00:00
|
|
|
BM_KEY_CONTROL_RETURN,
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_KEY_UNICODE,
|
|
|
|
BM_KEY_LAST
|
|
|
|
} bmKey;
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/**
|
|
|
|
* @name Menu Memory
|
|
|
|
* @{ */
|
2014-03-28 19:33:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create new bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param drawMode Render method to be used for this menu instance.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @return bmMenu for new menu instance, **NULL** if creation failed.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
|
|
|
bmMenu* bmMenuNew(bmDrawMode drawMode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance to be freed from memory.
|
|
|
|
*/
|
|
|
|
void bmMenuFree(bmMenu *menu);
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Release items inside bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance which items will be freed from memory.
|
|
|
|
*/
|
|
|
|
void bmMenuFreeItems(bmMenu *menu);
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Menu Memory */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Menu Properties
|
|
|
|
* @{ */
|
|
|
|
|
2014-04-10 17:09:34 +00:00
|
|
|
/**
|
|
|
|
* Set userdata pointer to bmMenu instance.
|
|
|
|
* Userdata will be carried unmodified by the instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to set userdata pointer.
|
|
|
|
* @param userdata Pointer to userdata.
|
|
|
|
*/
|
|
|
|
void bmMenuSetUserdata(bmMenu *menu, void *userdata);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get userdata pointer from bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance which userdata pointer to get.
|
|
|
|
* @return Pointer for unmodified userdata.
|
|
|
|
*/
|
|
|
|
void* bmMenuGetUserdata(bmMenu *menu);
|
|
|
|
|
2014-04-14 16:25:04 +00:00
|
|
|
/**
|
|
|
|
* Set filter text to bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to set filter.
|
|
|
|
* @param filter Null terminated C "string" to act as filter.
|
|
|
|
*/
|
|
|
|
void bmMenuSetFilter(bmMenu *menu, const char *filter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get filter text from bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to get filter.
|
|
|
|
* @return Const pointer to current filter text, may be **NULL** if empty.
|
|
|
|
*/
|
|
|
|
const char* bmMenuGetFilter(bmMenu *menu);
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Set active filter mode to bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to set filter mode.
|
|
|
|
* @param mode bmFilterMode constant.
|
|
|
|
*/
|
|
|
|
void bmMenuSetFilterMode(bmMenu *menu, bmFilterMode mode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get active filter mode from bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to get filter mode.
|
|
|
|
* @return bmFilterMode constant.
|
|
|
|
*/
|
|
|
|
bmFilterMode bmMenuGetFilterMode(const bmMenu *menu);
|
|
|
|
|
2014-04-14 16:25:16 +00:00
|
|
|
/**
|
|
|
|
* Set selection wrapping on/off.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to toggle selection wrapping.
|
|
|
|
* @param int 1 == on, 0 == off.
|
|
|
|
*/
|
|
|
|
void bmMenuSetWrap(bmMenu *menu, int wrap);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get selection wrapping state.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to get selection wrapping state.
|
|
|
|
* @return int for wrap state.
|
|
|
|
*/
|
|
|
|
int bmMenuGetWrap(const bmMenu *menu);
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Set title to bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to set title.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param title C "string" to set as title, can be **NULL** for empty title.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
|
|
|
int bmMenuSetTitle(bmMenu *menu, const char *title);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get title from bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where to get title from.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @return Pointer to null terminated C "string", can be **NULL** for empty title.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
|
|
|
const char* bmMenuGetTitle(const bmMenu *menu);
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Properties */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Menu Items
|
|
|
|
* @{ */
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Add item to bmMenu instance at specific index.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where item will be added.
|
|
|
|
* @param item bmItem instance to add.
|
|
|
|
* @param index Index where item will be added.
|
|
|
|
* @return 1 on successful add, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuAddItemAt(bmMenu *menu, bmItem *item, unsigned int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add item to bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where item will be added.
|
|
|
|
* @param item bmItem instance to add.
|
|
|
|
* @return 1 on successful add, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuAddItem(bmMenu *menu, bmItem *item);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove item from bmMenu instance at specific index.
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* @warning The item won't be freed, use bmItemFree to do that.
|
|
|
|
*
|
2014-04-09 22:09:35 +00:00
|
|
|
* @param menu bmMenu instance from where item will be removed.
|
|
|
|
* @param index Index of item to remove.
|
|
|
|
* @return 1 on successful add, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuRemoveItemAt(bmMenu *menu, unsigned int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove item from bmMenu instance.
|
2014-04-10 14:26:42 +00:00
|
|
|
*
|
|
|
|
* @warning The item won't be freed, use bmItemFree to do that.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
|
|
|
* @param menu bmMenu instance from where item will be removed.
|
|
|
|
* @param item bmItem instance to remove.
|
|
|
|
* @return 1 on successful add, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuRemoveItem(bmMenu *menu, bmItem *item);
|
|
|
|
|
|
|
|
/**
|
2014-04-10 17:04:06 +00:00
|
|
|
* Highlight item in menu by index.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-04-10 17:04:06 +00:00
|
|
|
* @param menu bmMenu instance from where to highlight item.
|
2014-04-10 17:12:42 +00:00
|
|
|
* @param index Index of item to highlight.
|
2014-04-10 17:04:06 +00:00
|
|
|
* @return 1 on successful highlight, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuSetHighlightedIndex(bmMenu *menu, unsigned int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlight item in menu.
|
2014-04-10 14:26:42 +00:00
|
|
|
*
|
2014-04-10 17:04:06 +00:00
|
|
|
* @param menu bmMenu instance from where to highlight item.
|
|
|
|
* @param item bmItem instance to highlight.
|
|
|
|
* @return 1 on successful highlight, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuSetHighlighted(bmMenu *menu, bmItem *item);
|
|
|
|
|
|
|
|
/**
|
2014-04-10 17:11:41 +00:00
|
|
|
* Get highlighted item from bmMenu instance.
|
2014-04-10 17:04:06 +00:00
|
|
|
*
|
2014-04-10 17:19:15 +00:00
|
|
|
* @warning The pointer returned by this function may be invalid after items change.
|
|
|
|
*
|
2014-04-10 17:11:41 +00:00
|
|
|
* @param menu bmMenu instance from where to get highlighted item.
|
|
|
|
* @return Selected bmItem instance, **NULL** if none highlighted.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2014-04-10 17:11:41 +00:00
|
|
|
bmItem* bmMenuGetHighlightedItem(const bmMenu *menu);
|
2014-04-10 17:04:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set selected items to bmMenu instance.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where items will be set.
|
|
|
|
* @param items Array of bmItem pointers to set.
|
|
|
|
* @param nmemb Total count of items in array.
|
|
|
|
* @return 1 on successful set, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuSetSelectedItems(bmMenu *menu, bmItem **items, unsigned int nmemb);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-04-10 17:11:41 +00:00
|
|
|
* Get selected items from bmMenu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-04-10 17:19:15 +00:00
|
|
|
* @warning The pointer returned by this function may be invalid after selection or items change.
|
|
|
|
*
|
2014-04-10 17:11:41 +00:00
|
|
|
* @param menu bmMenu instance from where to get selected items.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
|
2014-04-09 22:09:35 +00:00
|
|
|
* @return Pointer to array of bmItem pointers.
|
|
|
|
*/
|
2014-04-10 17:11:41 +00:00
|
|
|
bmItem** bmMenuGetSelectedItems(const bmMenu *menu, unsigned int *outNmemb);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set items to bmMenu instance.
|
|
|
|
* Will replace all the old items on bmMenu instance.
|
|
|
|
*
|
|
|
|
* If items is **NULL**, or nmemb is zero, all items will be freed from the menu.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance where items will be set.
|
|
|
|
* @param items Array of bmItem pointers to set.
|
|
|
|
* @param nmemb Total count of items in array.
|
|
|
|
* @return 1 on successful set, 0 on failure.
|
|
|
|
*/
|
|
|
|
int bmMenuSetItems(bmMenu *menu, const bmItem **items, unsigned int nmemb);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 17:04:06 +00:00
|
|
|
/**
|
|
|
|
* Get items from bmMenu instance.
|
|
|
|
*
|
|
|
|
* @warning The pointer returned by this function may be invalid after removing or adding new items.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance from where to get items.
|
|
|
|
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
|
|
|
|
* @return Pointer to array of bmItem pointers.
|
|
|
|
*/
|
|
|
|
bmItem** bmMenuGetItems(const bmMenu *menu, unsigned int *outNmemb);
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-04-10 17:11:41 +00:00
|
|
|
* Get filtered (displayed) items from bmMenu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-04-10 17:11:41 +00:00
|
|
|
* @warning The pointer returned by this function _will_ be invalid when menu internally filters its list again.
|
|
|
|
* Do not store this pointer.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-04-10 17:11:41 +00:00
|
|
|
* @param menu bmMenu instance from where to get filtered items.
|
|
|
|
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
|
|
|
|
* @return Pointer to array of bmItem pointers.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2014-04-10 17:11:41 +00:00
|
|
|
bmItem** bmMenuGetFilteredItems(const bmMenu *menu, unsigned int *outNmemb);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Menu Items */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Menu Logic
|
|
|
|
* @{ */
|
|
|
|
|
2014-03-28 19:33:20 +00:00
|
|
|
/**
|
|
|
|
* Render bmMenu instance using chosen draw method.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance to be rendered.
|
|
|
|
*/
|
2014-04-09 22:09:35 +00:00
|
|
|
void bmMenuRender(const bmMenu *menu);
|
|
|
|
|
2014-04-10 20:05:13 +00:00
|
|
|
/**
|
|
|
|
* Trigger filtering of menu manually.
|
|
|
|
* This is useful when adding new items and want to dynamically see them filtered.
|
|
|
|
*
|
|
|
|
* Do note that filtering might be heavy, so you should only call it after batch manipulation of items.
|
|
|
|
* Not after manipulation of each single item.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance which to filter.
|
|
|
|
*/
|
|
|
|
void bmMenuFilter(bmMenu *menu);
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Poll key and unicode from underlying UI toolkit.
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* This function will block on @link ::bmDrawMode BM_DRAW_MODE_CURSES @endlink draw mode.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
|
|
|
* @param menu bmMenu instance from which to poll.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param outUnicode Reference to unsigned int.
|
2014-04-09 22:09:35 +00:00
|
|
|
* @return bmKey for polled key.
|
|
|
|
*/
|
2014-04-10 14:26:42 +00:00
|
|
|
bmKey bmMenuGetKey(bmMenu *menu, unsigned int *outUnicode);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Advances menu logic with key and unicode as input.
|
|
|
|
*
|
|
|
|
* @param menu bmMenu instance to be advanced.
|
2014-04-10 10:08:38 +00:00
|
|
|
* @param key Key input that will advance menu logic.
|
|
|
|
* @param unicode Unicode input that will advance menu logic.
|
2014-04-09 22:09:35 +00:00
|
|
|
* @return bmRunResult for menu state.
|
|
|
|
*/
|
|
|
|
bmRunResult bmMenuRunWithKey(bmMenu *menu, bmKey key, unsigned int unicode);
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Menu Logic */
|
|
|
|
|
|
|
|
/** @} Menu */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Item
|
|
|
|
* @{ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Item Memory
|
|
|
|
* @{ */
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Allocate a new item.
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param text Pointer to null terminated C "string", can be **NULL** for empty text.
|
|
|
|
* @return bmItem for new item instance, **NULL** if creation failed.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
|
|
|
bmItem* bmItemNew(const char *text);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release bmItem instance.
|
|
|
|
*
|
|
|
|
* @param item bmItem instance to be freed from memory.
|
|
|
|
*/
|
|
|
|
void bmItemFree(bmItem *item);
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Item Memory */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Item Properties
|
|
|
|
* @{ */
|
|
|
|
|
2014-04-10 17:09:34 +00:00
|
|
|
/**
|
|
|
|
* Set userdata pointer to bmItem instance.
|
|
|
|
* Userdata will be carried unmodified by the instance.
|
|
|
|
*
|
|
|
|
* @param item bmItem instance where to set userdata pointer.
|
|
|
|
* @param userdata Pointer to userdata.
|
|
|
|
*/
|
|
|
|
void bmItemSetUserdata(bmItem *item, void *userdata);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get userdata pointer from bmItem instance.
|
|
|
|
*
|
|
|
|
* @param item bmItem instance which userdata pointer to get.
|
|
|
|
* @return Pointer for unmodified userdata.
|
|
|
|
*/
|
|
|
|
void* bmItemGetUserdata(bmItem *item);
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Set text to bmItem instance.
|
|
|
|
*
|
|
|
|
* @param item bmItem instance where to set text.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param text C "string" to set as text, can be **NULL** for empty text.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
|
|
|
int bmItemSetText(bmItem *item, const char *text);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get text from bmItem instance.
|
|
|
|
*
|
|
|
|
* @param item bmItem instance where to get text from.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @return Pointer to null terminated C "string", can be **NULL** for empty text.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
|
|
|
const char* bmItemGetText(const bmItem *item);
|
2014-03-28 19:33:20 +00:00
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Item Properties */
|
|
|
|
|
|
|
|
/** @} Item */
|
|
|
|
|
2014-03-28 19:33:20 +00:00
|
|
|
/* vim: set ts=8 sw=4 tw=0 :*/
|