2 * Copyright (C) 2009 Sony Computer Entertainment Inc.
3 * Copyright 2009 Sony Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #if !defined(_PB_NC_CUI_H)
24 #include "ui/common/joystick.h"
25 #include "ui/common/timer.h"
31 struct pb_kexec_data *kd;
34 const struct device *dev;
35 const struct boot_option *opt;
40 * struct cui - Data structure defining a cui state machine.
41 * @c_sig: Signature for callback type checking, should be cui_sig.
42 * @abort: When set to true signals the state machine to exit.
43 * @current: Pointer to the active nc object.
44 * @main: Pointer to the user supplied main menu.
46 * Device boot_options are dynamically added and removed from the @main
55 struct nc_scr *current;
57 struct ui_timer timer;
60 unsigned int default_item;
61 int (*on_kexec)(struct cui *cui, struct cui_opt_data *cod);
64 struct cui *cui_init(void* platform_info,
65 int (*on_kexec)(struct cui *, struct cui_opt_data *),
66 int (*js_map)(const struct js_event *e), int start_deamon, int dry_run);
67 struct nc_scr *cui_set_current(struct cui *cui, struct nc_scr *scr);
68 int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item);
69 int cui_ked_run(struct pmenu_item *item);
71 /* convenience routines */
73 void cui_abort(struct cui *cui);
74 void cui_resize(struct cui *cui);
75 void cui_on_exit(struct pmenu *menu);
76 void cui_on_open(struct pmenu *menu);
77 int cui_run_cmd(struct pmenu_item *item);
79 static inline struct cui *cui_from_arg(void *arg)
81 struct cui *cui = (struct cui *)arg;
83 assert(cui->c_sig == pb_cui_sig);
87 static inline struct cui *cui_from_pmenu(struct pmenu *menu)
89 return cui_from_arg(menu->scr.ui_ctx);
92 static inline struct cui *cui_from_item(struct pmenu_item *item)
94 return cui_from_pmenu(item->pmenu);
97 static inline struct cui *cui_from_timer(struct ui_timer *timer)
101 cui = (struct cui *)((char *)timer
102 - (size_t)&((struct cui *)0)->timer);
103 assert(cui->c_sig == pb_cui_sig);