AmendHub

Download

jcs

/

wallops

/

focusable.h

 

(View History)

jcs   focusable: Assign an id to each window Latest amendment: 98 on 2024-09-12

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 short id;
25 bool visible;
26 void *cookie;
27 bool modal;
28 short (*wait_type)(struct focusable *focusable);
29 void (*idle)(struct focusable *focusable, EventRecord *event);
30 void (*update)(struct focusable *focusable, EventRecord *event);
31 void (*key_down)(struct focusable *focusable, EventRecord *event);
32 void (*mouse_down)(struct focusable *focusable, EventRecord *event);
33 void (*resize)(struct focusable *focusable, EventRecord *event);
34 bool (*menu)(struct focusable *focusable, short menu, short item);
35 void (*update_menu)(struct focusable *focusable);
36 void (*suspend)(struct focusable *focusable, EventRecord *event);
37 void (*resume)(struct focusable *focusable, EventRecord *event);
38 bool (*close)(struct focusable *focusable);
39 bool (*quit)(struct focusable *focusable);
40 void (*atexit)(struct focusable *focusable);
41 };
42 extern struct focusable **focusables;
43 extern short nfocusables;
44
45 struct focusable * focusable_find(GrafPtr win);
46 struct focusable * focusable_focused(void);
47 void focusable_add(struct focusable *focusable);
48 bool focusable_show(struct focusable *focusable);
49 bool focusable_close(struct focusable *focusable);
50 void focusable_hide(struct focusable *focusable);
51 bool focusables_quit(void);
52
53 #endif