HelenOS sources
This source file includes following definitions.
- ui_fixed_create
- ui_fixed_destroy
- ui_fixed_ctl
- ui_fixed_add
- ui_fixed_remove
- ui_fixed_first
- ui_fixed_next
- ui_fixed_paint
- ui_fixed_kbd_event
- ui_fixed_pos_event
- ui_fixed_unfocus
- ui_fixed_ctl_destroy
- ui_fixed_ctl_paint
- ui_fixed_ctl_kbd_event
- ui_fixed_ctl_pos_event
- ui_fixed_ctl_unfocus
#include <adt/list.h>
#include <assert.h>
#include <errno.h>
#include <io/pos_event.h>
#include <stdlib.h>
#include <ui/control.h>
#include <ui/fixed.h>
#include "../private/control.h"
#include "../private/fixed.h"
static void ui_fixed_ctl_destroy(void *);
static errno_t ui_fixed_ctl_paint(void *);
static ui_evclaim_t ui_fixed_ctl_kbd_event(void *, kbd_event_t *);
static ui_evclaim_t ui_fixed_ctl_pos_event(void *, pos_event_t *);
static void ui_fixed_ctl_unfocus(void *, unsigned);
ui_control_ops_t ui_fixed_ops = {
.destroy = ui_fixed_ctl_destroy,
.paint = ui_fixed_ctl_paint,
.kbd_event = ui_fixed_ctl_kbd_event,
.pos_event = ui_fixed_ctl_pos_event,
.unfocus = ui_fixed_ctl_unfocus
};
errno_t ui_fixed_create(ui_fixed_t **rfixed)
{
ui_fixed_t *fixed;
errno_t rc;
fixed = calloc(1, sizeof(ui_fixed_t));
if (fixed == NULL)
return ENOMEM;
rc = ui_control_new(&ui_fixed_ops, (void *) fixed, &fixed->control);
if (rc != EOK) {
free(fixed);
return rc;
}
list_initialize(&fixed->elem);
*rfixed = fixed;
return EOK;
}
void ui_fixed_destroy(ui_fixed_t *fixed)
{
ui_fixed_elem_t *elem;
ui_control_t *control;
if (fixed == NULL)
return;
elem = ui_fixed_first(fixed);
while (elem != NULL) {
control = elem->control;
ui_fixed_remove(fixed, control);
ui_control_destroy(control);
elem = ui_fixed_first(fixed);
}
ui_control_delete(fixed->control);
free(fixed);
}
ui_control_t *ui_fixed_ctl(ui_fixed_t *fixed)
{
return fixed->control;
}
errno_t ui_fixed_add(ui_fixed_t *fixed, ui_control_t *control)
{
ui_fixed_elem_t *elem;
elem = calloc(1, sizeof(ui_fixed_elem_t));
if (elem == NULL)
return ENOMEM;
elem->fixed = fixed;
elem->control = control;
control->elemp = (void *) elem;
list_append(&elem->lelems, &fixed->elem);
return EOK;
}
void ui_fixed_remove(ui_fixed_t *fixed, ui_control_t *control)
{
ui_fixed_elem_t *elem;
elem = (ui_fixed_elem_t *) control->elemp;
assert(elem->fixed == fixed);
list_remove(&elem->lelems);
control->elemp = NULL;
free(elem);
}
ui_fixed_elem_t *ui_fixed_first(ui_fixed_t *fixed)
{
link_t *link;
link = list_first(&fixed->elem);
if (link == NULL)
return NULL;
return list_get_instance(link, ui_fixed_elem_t, lelems);
}
ui_fixed_elem_t *ui_fixed_next(ui_fixed_elem_t *cur)
{
link_t *link;
link = list_next(&cur->lelems, &cur->fixed->elem);
if (link == NULL)
return NULL;
return list_get_instance(link, ui_fixed_elem_t, lelems);
}
errno_t ui_fixed_paint(ui_fixed_t *fixed)
{
ui_fixed_elem_t *elem;
errno_t rc;
elem = ui_fixed_first(fixed);
while (elem != NULL) {
rc = ui_control_paint(elem->control);
if (rc != EOK)
return rc;
elem = ui_fixed_next(elem);
}
return EOK;
}
ui_evclaim_t ui_fixed_kbd_event(ui_fixed_t *fixed, kbd_event_t *event)
{
ui_fixed_elem_t *elem;
ui_evclaim_t claimed;
elem = ui_fixed_first(fixed);
while (elem != NULL) {
claimed = ui_control_kbd_event(elem->control, event);
if (claimed == ui_claimed)
return ui_claimed;
elem = ui_fixed_next(elem);
}
return ui_unclaimed;
}
ui_evclaim_t ui_fixed_pos_event(ui_fixed_t *fixed, pos_event_t *event)
{
ui_fixed_elem_t *elem;
ui_evclaim_t claimed;
elem = ui_fixed_first(fixed);
while (elem != NULL) {
claimed = ui_control_pos_event(elem->control, event);
if (claimed == ui_claimed)
return ui_claimed;
elem = ui_fixed_next(elem);
}
return ui_unclaimed;
}
void ui_fixed_unfocus(ui_fixed_t *fixed, unsigned nfocus)
{
ui_fixed_elem_t *elem;
elem = ui_fixed_first(fixed);
while (elem != NULL) {
ui_control_unfocus(elem->control, nfocus);
elem = ui_fixed_next(elem);
}
}
void ui_fixed_ctl_destroy(void *arg)
{
ui_fixed_t *fixed = (ui_fixed_t *) arg;
ui_fixed_destroy(fixed);
}
errno_t ui_fixed_ctl_paint(void *arg)
{
ui_fixed_t *fixed = (ui_fixed_t *) arg;
return ui_fixed_paint(fixed);
}
ui_evclaim_t ui_fixed_ctl_kbd_event(void *arg, kbd_event_t *event)
{
ui_fixed_t *fixed = (ui_fixed_t *) arg;
return ui_fixed_kbd_event(fixed, event);
}
ui_evclaim_t ui_fixed_ctl_pos_event(void *arg, pos_event_t *event)
{
ui_fixed_t *fixed = (ui_fixed_t *) arg;
return ui_fixed_pos_event(fixed, event);
}
void ui_fixed_ctl_unfocus(void *arg, unsigned nfocus)
{
ui_fixed_t *fixed = (ui_fixed_t *) arg;
ui_fixed_unfocus(fixed, nfocus);
}
HelenOS homepage, sources at GitHub