HelenOS sources
This source file includes following definitions.
- ui_tab_set_create
- ui_tab_set_destroy
- ui_tab_set_ctl
- ui_tab_set_set_rect
- ui_tab_set_paint
- ui_tab_set_select
- ui_tab_set_kbd_event
- ui_tab_set_pos_event
- ui_tab_set_ctl_destroy
- ui_tab_set_ctl_paint
- ui_tab_set_ctl_kbd_event
- ui_tab_set_ctl_pos_event
#include <adt/list.h>
#include <errno.h>
#include <gfx/render.h>
#include <io/pos_event.h>
#include <stdlib.h>
#include <ui/control.h>
#include <ui/tab.h>
#include <ui/tabset.h>
#include <ui/window.h>
#include "../private/tab.h"
#include "../private/tabset.h"
#include "../private/resource.h"
static void ui_tab_set_ctl_destroy(void *);
static errno_t ui_tab_set_ctl_paint(void *);
static ui_evclaim_t ui_tab_set_ctl_kbd_event(void *, kbd_event_t *);
static ui_evclaim_t ui_tab_set_ctl_pos_event(void *, pos_event_t *);
ui_control_ops_t ui_tab_set_ops = {
.destroy = ui_tab_set_ctl_destroy,
.paint = ui_tab_set_ctl_paint,
.kbd_event = ui_tab_set_ctl_kbd_event,
.pos_event = ui_tab_set_ctl_pos_event
};
errno_t ui_tab_set_create(ui_resource_t *res, ui_tab_set_t **rtabset)
{
ui_tab_set_t *tabset;
errno_t rc;
tabset = calloc(1, sizeof(ui_tab_set_t));
if (tabset == NULL)
return ENOMEM;
rc = ui_control_new(&ui_tab_set_ops, (void *) tabset, &tabset->control);
if (rc != EOK) {
free(tabset);
return rc;
}
tabset->res = res;
list_initialize(&tabset->tabs);
*rtabset = tabset;
return EOK;
}
void ui_tab_set_destroy(ui_tab_set_t *tabset)
{
ui_tab_t *tab;
if (tabset == NULL)
return;
tab = ui_tab_first(tabset);
while (tab != NULL) {
ui_tab_destroy(tab);
tab = ui_tab_first(tabset);
}
ui_control_delete(tabset->control);
free(tabset);
}
ui_control_t *ui_tab_set_ctl(ui_tab_set_t *tabset)
{
return tabset->control;
}
void ui_tab_set_set_rect(ui_tab_set_t *tabset, gfx_rect_t *rect)
{
tabset->rect = *rect;
}
errno_t ui_tab_set_paint(ui_tab_set_t *tabset)
{
ui_resource_t *res;
ui_tab_t *tab;
errno_t rc;
res = tabset->res;
if (tabset->selected != NULL) {
rc = ui_tab_paint_body_frame(tabset->selected);
if (rc != EOK)
goto error;
}
tab = ui_tab_first(tabset);
while (tab != NULL) {
rc = ui_tab_paint(tab);
if (rc != EOK)
return rc;
tab = ui_tab_next(tab);
}
rc = gfx_update(res->gc);
if (rc != EOK)
goto error;
return EOK;
error:
return rc;
}
void ui_tab_set_select(ui_tab_set_t *tabset, ui_tab_t *tab)
{
tabset->selected = tab;
(void) ui_tab_set_paint(tabset);
}
ui_evclaim_t ui_tab_set_kbd_event(ui_tab_set_t *tabset, kbd_event_t *event)
{
ui_tab_t *tab;
ui_evclaim_t claim;
tab = ui_tab_first(tabset);
while (tab != NULL) {
claim = ui_tab_kbd_event(tab, event);
if (claim == ui_claimed)
return ui_claimed;
tab = ui_tab_next(tab);
}
return ui_unclaimed;
}
ui_evclaim_t ui_tab_set_pos_event(ui_tab_set_t *tabset, pos_event_t *event)
{
ui_tab_t *tab;
ui_evclaim_t claim;
tab = ui_tab_first(tabset);
while (tab != NULL) {
claim = ui_tab_pos_event(tab, event);
if (claim == ui_claimed)
return ui_claimed;
tab = ui_tab_next(tab);
}
return ui_unclaimed;
}
static void ui_tab_set_ctl_destroy(void *arg)
{
ui_tab_set_t *tabset = (ui_tab_set_t *) arg;
ui_tab_set_destroy(tabset);
}
static errno_t ui_tab_set_ctl_paint(void *arg)
{
ui_tab_set_t *tabset = (ui_tab_set_t *) arg;
return ui_tab_set_paint(tabset);
}
static ui_evclaim_t ui_tab_set_ctl_kbd_event(void *arg, kbd_event_t *event)
{
ui_tab_set_t *tabset = (ui_tab_set_t *) arg;
return ui_tab_set_kbd_event(tabset, event);
}
static ui_evclaim_t ui_tab_set_ctl_pos_event(void *arg, pos_event_t *event)
{
ui_tab_set_t *tabset = (ui_tab_set_t *) arg;
return ui_tab_set_pos_event(tabset, event);
}
HelenOS homepage, sources at GitHub