AmendHub

Download

jcs

/

subtext

/

focusable.h

 

(View History)

jcs   focusable: Allow add_focusable to fail Latest amendment: 339 on 2023-03-02

1 /*
2 * Copyright (c) 2021-2022 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef __FOCUSABLE_H__
18 #define __FOCUSABLE_H__
19
20 #include "util.h"
21
22 struct focusable {
23 WindowPtr win;
24 bool visible;
25 void *cookie;
26 short (*wait_type)(struct focusable *focusable);
27 void (*idle)(struct focusable *focusable, EventRecord *event);
28 void (*update)(struct focusable *focusable, EventRecord *event);
29 void (*key_down)(struct focusable *focusable, EventRecord *event);
30 void (*mouse_down)(struct focusable *focusable, EventRecord *event);
31 void (*resize)(struct focusable *focusable, EventRecord *event);
32 bool (*menu)(struct focusable *focusable, short menu, short item);
33 void (*close)(struct focusable *focusable, EventRecord *event);
34 void (*suspend)(struct focusable *focusable, EventRecord *event);
35 void (*resume)(struct focusable *focusable, EventRecord *event);
36 bool (*quit)(struct focusable *focusable);
37 void (*atexit)(struct focusable *focusable);
38 };
39 extern struct focusable **focusables;
40 extern short nfocusables;
41
42 struct focusable * find_focusable(GrafPtr win);
43 bool add_focusable(struct focusable *focusable);
44 void show_focusable(struct focusable *focusable);
45 void destroy_focusable(struct focusable *focusable);
46 void hide_focusable(struct focusable *focusable);
47
48 #endif