blob: f6c1739bad382a4d05d2a8445a380422bda68c35 [file] [log] [blame]
kthacker62e146c2006-04-17 15:11:35 +00001/*
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 2006/04/17 15:18:21 kthacker Exp $
33 *
34 */
35
36#include "contiki.h"
37#include <string.h>
38
39
40static struct ctk_window welcomedialog;
41const static struct ctk_label welcomelabel1 =
42 {CTK_LABEL(1, 1, 30, 1, "Welcome to " CONTIKI_VERSION_STRING "!")};
43const static struct ctk_label welcomelabel2 =
44 {CTK_LABEL(2, 4, 28, 1, "F1 - open menus")};
45const static struct ctk_label welcomelabel3 =
PulkoMandya8e43962014-07-03 18:54:38 +020046 {CTK_LABEL(2, 6, 28, 1, "F2 - cycle windows")};
kthacker62e146c2006-04-17 15:11:35 +000047const static struct ctk_label welcomelabel4 =
48 {CTK_LABEL(2, 8, 28, 1, "F7 - select up")};
49const static struct ctk_label welcomelabel5 =
50 {CTK_LABEL(2, 10, 28, 1, "F4 - select down")};
51const static struct ctk_label welcomelabel6 =
52 {CTK_LABEL(2, 12, 28, 1, "Return - activate selected")};
53const static struct ctk_label welcomelabel7 =
54 {CTK_LABEL(3, 15, 25, 1, "Press any key to continue")};
55
56
57EK_EVENTHANDLER(welcome_eventhandler, ev, data);
58
59EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
60static ek_id_t id = EK_ID_NONE;
61
62/*-----------------------------------------------------------------------------------*/
63LOADER_INIT_FUNC(welcome_init, arg)
64{
65 arg_free(arg);
66
67 if(id == EK_ID_NONE) {
68 id = ek_start(&p);
69 }
70}
71/*-----------------------------------------------------------------------------------*/
72static void
73welcome_quit(void)
74{
75 ctk_dialog_close();
76 ek_exit();
77 id = EK_ID_NONE;
78 LOADER_UNLOAD();
79}
80/*-----------------------------------------------------------------------------------*/
81/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
82EK_EVENTHANDLER(welcome_eventhandler, ev, data)
83{
84 unsigned char width;
85 EK_EVENTHANDLER_ARGS(ev, data);
86
87 if(ev == EK_EVENT_INIT) {
88 width = ctk_desktop_width(NULL);
89
90 if(width > 34) {
91 ctk_dialog_new(&welcomedialog, 32, 17);
92 } else {
93 ctk_dialog_new(&welcomedialog, width - 2, 17);
94 }
95 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
96 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
97 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
98 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
99 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
100 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
101 CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);
102
103 ctk_dialog_open(&welcomedialog);
104
105 } else if(ev == EK_EVENT_REQUEST_EXIT ||
106 ev == ctk_signal_keypress) {
107 welcome_quit();
108 }
109}
110/*-----------------------------------------------------------------------------------*/