blob: 70a359cb161417c5028c537f08496992293e94aa [file] [log] [blame]
PulkoMandy5500b682021-09-21 21:27:13 +02001/*
2 * Copyright (c) 2002, Adam Dunkels.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
14 * 3. The name of the author may not be used to endorse or promote
15 * products derived from this software without specific prior
16 * written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * This file is part of the Contiki desktop environment
31 *
32 * $Id: welcome.c,v 1.1 2004/09/12 13:11:51 adamdunkels Exp $
33 *
34 */
35
36#include "ek.h"
37#include "ctk.h"
38#include <string.h>
39
40
41static struct ctk_window welcomedialog;
42static struct ctk_label welcomelabel1 =
43 {CTK_LABEL(1, 1, 30, 1, "Welcome to Contiki!")};
44static struct ctk_label welcomelabel2 =
45 {CTK_LABEL(2, 4, 28, 1, "F1 - open menus")};
46static struct ctk_label welcomelabel3 =
47 {CTK_LABEL(2, 6, 28, 1, "F3 - cycle windows")};
48static struct ctk_label welcomelabel4 =
49 {CTK_LABEL(2, 8, 28, 1, "F5 - select up")};
50static struct ctk_label welcomelabel5 =
51 {CTK_LABEL(2, 10, 28, 1, "F7 - select down")};
52static struct ctk_label welcomelabel6 =
53 {CTK_LABEL(2, 12, 28, 1, "Return - activate selected")};
54static struct ctk_label welcomelabel7 =
55 {CTK_LABEL(3, 15, 25, 1, "Press any key to continue")};
56
57
58EK_EVENTHANDLER(welcome_eventhandler, ev, data);
59
60EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
61static ek_id_t id = EK_ID_NONE;
62
63/*-----------------------------------------------------------------------------------*/
64LOADER_INIT_FUNC(welcome_init, arg)
65{
66 arg_free(arg);
67
68 if(id == EK_ID_NONE) {
69 id = ek_start(&p);
70 }
71}
72/*-----------------------------------------------------------------------------------*/
73static void
74welcome_quit(void)
75{
76 ctk_dialog_close();
77 ek_exit();
78 id = EK_ID_NONE;
79 LOADER_UNLOAD();
80}
81/*-----------------------------------------------------------------------------------*/
82/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
83EK_EVENTHANDLER(welcome_eventhandler, ev, data)
84{
85 unsigned char width;
86 EK_EVENTHANDLER_ARGS(ev, data);
87
88 if(ev == EK_EVENT_INIT) {
89 width = ctk_desktop_width(NULL);
90
91 if(width > 34) {
92 ctk_dialog_new(&welcomedialog, 32, 17);
93 } else {
94 ctk_dialog_new(&welcomedialog, width - 2, 17);
95 }
96 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
97 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
98 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
99 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
100 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
101 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
102 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);
103
104 ctk_dialog_open(&welcomedialog);
105
106 } else if(ev == EK_EVENT_REQUEST_EXIT ||
107 ev == ctk_signal_keypress) {
108 welcome_quit();
109 }
110}
111/*-----------------------------------------------------------------------------------*/