HelenOS sources
This source file includes following definitions.
- test_ctl_destroy
- test_ctl_paint
- test_ctl_kbd_event
- test_ctl_pos_event
- test_ctl_unfocus
- ui_test_ctl_create
- ui_test_ctl_destroy
- ui_test_ctl_ctl
#include <errno.h>
#include <stdlib.h>
#include <str.h>
#include <ui/control.h>
#include <ui/testctl.h>
#include "../private/testctl.h"
static void test_ctl_destroy(void *);
static errno_t test_ctl_paint(void *);
static ui_evclaim_t test_ctl_kbd_event(void *, kbd_event_t *);
static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
static void test_ctl_unfocus(void *, unsigned);
ui_control_ops_t ui_test_ctl_ops = {
.destroy = test_ctl_destroy,
.paint = test_ctl_paint,
.kbd_event = test_ctl_kbd_event,
.pos_event = test_ctl_pos_event,
.unfocus = test_ctl_unfocus
};
static void test_ctl_destroy(void *arg)
{
ui_test_ctl_t *testctl = (ui_test_ctl_t *)arg;
ui_tc_resp_t *resp = testctl->resp;
resp->destroy = true;
ui_test_ctl_destroy(testctl);
}
static errno_t test_ctl_paint(void *arg)
{
ui_test_ctl_t *testctl = (ui_test_ctl_t *)arg;
ui_tc_resp_t *resp = testctl->resp;
resp->paint = true;
return resp->rc;
}
static ui_evclaim_t test_ctl_kbd_event(void *arg, kbd_event_t *event)
{
ui_test_ctl_t *testctl = (ui_test_ctl_t *)arg;
ui_tc_resp_t *resp = testctl->resp;
resp->kbd = true;
resp->kevent = *event;
return resp->claim;
}
static ui_evclaim_t test_ctl_pos_event(void *arg, pos_event_t *event)
{
ui_test_ctl_t *testctl = (ui_test_ctl_t *)arg;
ui_tc_resp_t *resp = testctl->resp;
resp->pos = true;
resp->pevent = *event;
return resp->claim;
}
static void test_ctl_unfocus(void *arg, unsigned nfocus)
{
ui_test_ctl_t *testctl = (ui_test_ctl_t *)arg;
ui_tc_resp_t *resp = testctl->resp;
resp->unfocus = true;
resp->unfocus_nfocus = nfocus;
}
errno_t ui_test_ctl_create(ui_tc_resp_t *resp, ui_test_ctl_t **rtest)
{
ui_test_ctl_t *test;
errno_t rc;
test = calloc(1, sizeof(ui_test_ctl_t));
if (test == NULL)
return ENOMEM;
rc = ui_control_new(&ui_test_ctl_ops, (void *)test, &test->control);
if (rc != EOK) {
free(test);
return rc;
}
test->resp = resp;
*rtest = test;
return EOK;
}
void ui_test_ctl_destroy(ui_test_ctl_t *test)
{
if (test == NULL)
return;
ui_control_delete(test->control);
free(test);
}
ui_control_t *ui_test_ctl_ctl(ui_test_ctl_t *test)
{
return test->control;
}
HelenOS homepage, sources at GitHub