Made MAC_CONF_CHANNEL_CHECK_RATE identical to CLOCK_CONF_SECOND in order to make...
[contiki-2.x.git] / apps / about / about.c
blob1babdea50db8763aae3cd2eb2ac11bbd91b317a7
1 /*
2 * Copyright (c) 2002, Adam Dunkels.
3 * All rights reserved.
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.
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.
30 * This file is part of the Contiki desktop environment
32 * $Id: about.c,v 1.4 2008/02/08 22:48:28 oliverschmidt Exp $
36 #include <string.h>
38 #include "contiki.h"
39 #include "ctk/ctk.h"
40 #include "lib/petsciiconv.h"
42 static struct ctk_window aboutdialog;
43 static struct ctk_label aboutlabel1 =
44 {CTK_LABEL(2, 0, 28, 1, "The Contiki Operating System")};
45 static struct ctk_label aboutlabel2 =
46 {CTK_LABEL(3, 2, 28, 1, "A modern, Internet-enabled")};
47 static struct ctk_label aboutlabel3 =
48 {CTK_LABEL(6, 3, 20, 1, "operating system and")};
49 static struct ctk_label aboutlabel4 =
50 {CTK_LABEL(6, 4, 20, 1, "desktop environment.")};
52 static char abouturl_petscii[] = "http://www.sics.se/~adam/contiki/";
53 static char abouturl_ascii[40];
54 static struct ctk_hyperlink abouturl =
55 {CTK_HYPERLINK(0, 6, 32, "http://www.sics.se/~adam/contiki/",
56 abouturl_ascii)};
57 static struct ctk_button aboutclose =
58 {CTK_BUTTON(12, 8, 5, "Close")};
61 PROCESS(about_process, "About Contiki");
63 AUTOSTART_PROCESSES(&about_process);
65 /*-----------------------------------------------------------------------------------*/
66 static void
67 about_quit(void)
69 ctk_dialog_close();
70 process_exit(&about_process);
71 LOADER_UNLOAD();
73 /*-----------------------------------------------------------------------------------*/
74 PROCESS_THREAD(about_process, ev, data)
76 unsigned char width;
78 PROCESS_BEGIN();
80 width = ctk_desktop_width(NULL);
82 strcpy(abouturl_ascii, abouturl_petscii);
83 petsciiconv_toascii(abouturl_ascii, sizeof(abouturl_ascii));
85 if(width > 34) {
86 ctk_dialog_new(&aboutdialog, 32, 9);
87 } else {
88 ctk_dialog_new(&aboutdialog, width - 2, 9);
90 CTK_WIDGET_ADD(&aboutdialog, &aboutlabel1);
91 CTK_WIDGET_ADD(&aboutdialog, &aboutlabel2);
92 CTK_WIDGET_ADD(&aboutdialog, &aboutlabel3);
93 CTK_WIDGET_ADD(&aboutdialog, &aboutlabel4);
94 if(width > 34) {
95 CTK_WIDGET_ADD(&aboutdialog, &abouturl);
96 CTK_WIDGET_SET_FLAG(&abouturl, CTK_WIDGET_FLAG_MONOSPACE);
97 } else {
98 CTK_WIDGET_SET_XPOS(&aboutlabel1, 0);
99 CTK_WIDGET_SET_XPOS(&aboutlabel2, 0);
100 CTK_WIDGET_SET_XPOS(&aboutlabel3, 0);
101 CTK_WIDGET_SET_XPOS(&aboutlabel4, 0);
103 CTK_WIDGET_SET_XPOS(&aboutclose, 0);
105 CTK_WIDGET_ADD(&aboutdialog, &aboutclose);
106 CTK_WIDGET_FOCUS(&aboutdialog, &aboutclose);
108 ctk_dialog_open(&aboutdialog);
110 while(1) {
111 PROCESS_WAIT_EVENT();
112 if(ev == PROCESS_EVENT_EXIT) {
113 about_quit();
114 PROCESS_EXIT();
115 } else if(ev == ctk_signal_button_activate) {
116 if(data == (process_data_t)&aboutclose) {
117 about_quit();
118 PROCESS_EXIT();
120 } else if(ev == ctk_signal_hyperlink_activate) {
121 if((struct ctk_widget *)data == (struct ctk_widget *)&abouturl) {
122 about_quit();
123 PROCESS_EXIT();
128 PROCESS_END();
130 /*-----------------------------------------------------------------------------------*/