HelenOS sources
This source file includes following definitions.
- ui_menu_dd_create
- ui_menu_dd_destroy
- ui_menu_dd_first
- ui_menu_dd_next
- ui_menu_dd_last
- ui_menu_dd_prev
- ui_menu_dd_caption
- ui_menu_dd_get_accel
- ui_menu_dd_open
- ui_menu_dd_close
- ui_menu_dd_is_open
- ui_menu_dd_left
- ui_menu_dd_right
- ui_menu_dd_close_req
- ui_menu_dd_press_accel
#include <adt/list.h>
#include <errno.h>
#include <stdlib.h>
#include <str.h>
#include <ui/accel.h>
#include <ui/menu.h>
#include <ui/menudd.h>
#include <ui/menubar.h>
#include <ui/resource.h>
#include "../private/menubar.h"
#include "../private/menudd.h"
static void ui_menu_dd_left(ui_menu_t *, void *, sysarg_t);
static void ui_menu_dd_right(ui_menu_t *, void *, sysarg_t);
static void ui_menu_dd_close_req(ui_menu_t *, void *);
static void ui_menu_dd_press_accel(ui_menu_t *, void *, char32_t, sysarg_t);
static ui_menu_cb_t ui_menu_dd_menu_cb = {
.left = ui_menu_dd_left,
.right = ui_menu_dd_right,
.close_req = ui_menu_dd_close_req,
.press_accel = ui_menu_dd_press_accel
};
errno_t ui_menu_dd_create(ui_menu_bar_t *mbar, const char *caption,
ui_menu_dd_t **rmdd, ui_menu_t **rmenu)
{
errno_t rc;
ui_menu_dd_t *mdd;
mdd = calloc(1, sizeof(ui_menu_dd_t));
if (mdd == NULL)
return ENOMEM;
mdd->caption = str_dup(caption);
if (mdd->caption == NULL) {
free(mdd);
return ENOMEM;
}
rc = ui_menu_create(mbar->window, &mdd->menu);
if (rc != EOK) {
free(mdd->caption);
free(mdd);
return rc;
}
mdd->mbar = mbar;
list_append(&mdd->lmenudds, &mbar->menudds);
ui_menu_set_cb(mdd->menu, &ui_menu_dd_menu_cb, (void *)mdd);
if (rmdd != NULL)
*rmdd = mdd;
if (rmenu != NULL)
*rmenu = mdd->menu;
return EOK;
}
void ui_menu_dd_destroy(ui_menu_dd_t *mdd)
{
if (mdd == NULL)
return;
ui_menu_destroy(mdd->menu);
list_remove(&mdd->lmenudds);
free(mdd->caption);
free(mdd);
}
ui_menu_dd_t *ui_menu_dd_first(ui_menu_bar_t *mbar)
{
link_t *link;
link = list_first(&mbar->menudds);
if (link == NULL)
return NULL;
return list_get_instance(link, ui_menu_dd_t, lmenudds);
}
ui_menu_dd_t *ui_menu_dd_next(ui_menu_dd_t *cur)
{
link_t *link;
link = list_next(&cur->lmenudds, &cur->mbar->menudds);
if (link == NULL)
return NULL;
return list_get_instance(link, ui_menu_dd_t, lmenudds);
}
ui_menu_dd_t *ui_menu_dd_last(ui_menu_bar_t *mbar)
{
link_t *link;
link = list_last(&mbar->menudds);
if (link == NULL)
return NULL;
return list_get_instance(link, ui_menu_dd_t, lmenudds);
}
ui_menu_dd_t *ui_menu_dd_prev(ui_menu_dd_t *cur)
{
link_t *link;
link = list_prev(&cur->lmenudds, &cur->mbar->menudds);
if (link == NULL)
return NULL;
return list_get_instance(link, ui_menu_dd_t, lmenudds);
}
const char *ui_menu_dd_caption(ui_menu_dd_t *mdd)
{
return mdd->caption;
}
char32_t ui_menu_dd_get_accel(ui_menu_dd_t *mdd)
{
return ui_accel_get(mdd->caption);
}
errno_t ui_menu_dd_open(ui_menu_dd_t *mdd, gfx_rect_t *prect, sysarg_t idev_id)
{
return ui_menu_open(mdd->menu, prect, idev_id);
}
void ui_menu_dd_close(ui_menu_dd_t *mdd)
{
ui_menu_close(mdd->menu);
}
bool ui_menu_dd_is_open(ui_menu_dd_t *mdd)
{
return ui_menu_is_open(mdd->menu);
}
static void ui_menu_dd_left(ui_menu_t *menu, void *arg, sysarg_t idev_id)
{
ui_menu_dd_t *mdd = (ui_menu_dd_t *)arg;
(void)menu;
ui_menu_bar_left(mdd->mbar, idev_id);
}
static void ui_menu_dd_right(ui_menu_t *menu, void *arg, sysarg_t idev_id)
{
ui_menu_dd_t *mdd = (ui_menu_dd_t *)arg;
(void)menu;
ui_menu_bar_right(mdd->mbar, idev_id);
}
static void ui_menu_dd_close_req(ui_menu_t *menu, void *arg)
{
ui_menu_dd_t *mdd = (ui_menu_dd_t *)arg;
(void)menu;
ui_menu_bar_deactivate(mdd->mbar);
}
static void ui_menu_dd_press_accel(ui_menu_t *menu, void *arg, char32_t c,
sysarg_t kbd_id)
{
ui_menu_dd_t *mdd = (ui_menu_dd_t *)arg;
(void)menu;
ui_menu_bar_press_accel(mdd->mbar, c, kbd_id);
}
HelenOS homepage, sources at GitHub