Debian Codegraph @

terps/tads/tads2/osifcext.h

raw symbols SCIP
1 /* Copyright (c) 2005 by Michael J. Roberts. All Rights Reserved. */
2 /*
3 Name
4 osifcext.h - tads OS interface extensions
5 Function
6 This header defines some extensions to the portable interfaces to the OS,
7 beyond the interfaces provided in osifc.h. These functions are optional
8 extensions, for use in tads 3: platforms generally only need to implement
9 these functions if the tads 3 tads-io-ext function set is used.
10 Notes
11
12 Modified
13 03/02/05 MJRoberts - Creation
14 */
15
16 #ifndef OSIFCEXT_H
17 #define OSIFCEXT_H
18
19 /* if we're in C++ mode, explicitly specify C-style linkage */
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24
25 /* ------------------------------------------------------------------------ */
26 /*
27 * Open a popup menu window. The new window should be opened at the given
28 * x,y coordinates (given in pixels, relative to the top left of the main
29 * game window), and should be drawn in a style consistent with local
30 * system conventions for context menus. If 'default_pos' is true, ignore
31 * the x,y coordinates and place the menu at a suitable default position,
32 * according to local conventions; for example, on Windows, the default
33 * position for a context menu is at the current mouse position. The given
34 * HTML text is to be used as the contents of the new window. The window
35 * should be sized to fit the contents.
36 *
37 * The window should have essentially the same lifetime as a context menu
38 * would have. That is, if the user clicks the mouse outside of the popup,
39 * the popup should be automatically closed. If the user clicks on a
40 * hyperlink in the popup, the hyperlink should fire its event as normal,
41 * and the popup window should be closed.
42 *
43 * If we successfully show the menu, and the user clicks on a hyperlink
44 * item from the menu, we'll return OSPOP_HREF, and we'll fill in *evt with
45 * the event information for the hyperlink selection. If we successfully
46 * show the menu, but the user clicks outside the menu or otherwise cancels
47 * the menu without making a selection, we'll return OSPOP_CANCEL. If we
48 * can't show the menu, we'll return OSPOP_FAIL. If the application is
49 * shut down while we're showing the menu (because the user closes the app,
50 * for example, or because the system is shutting down) we'll return
51 * OSPOP_EOF.
52 */
53 int os_show_popup_menu(int default_pos, int x, int y,
54 const char *txt, size_t txtlen,
55 union os_event_info_t *evt);
56
57 #define OSPOP_FAIL 0 /* can't show popup menu */
58 #define OSPOP_HREF 1 /* user clicked on a hyperlink in the menu */
59 #define OSPOP_CANCEL 2 /* user canceled without making a selection */
60 #define OSPOP_EOF 3 /* application is closing */
61
62
63 /* close the extern "C" if we're in C++ mode */
64 #ifdef __cplusplus
65 }
66 #endif
67
68 /* ------------------------------------------------------------------------ */
69 /*
70 * Enable/disable a System Menu Command event in os_get_event().
71 *
72 * Some interpreters provide menu commands for the common "system" commands
73 * that most games support, such as SAVE, RESTORE, UNDO, and QUIT. The
74 * older interpreters didn't have any support for a menu interface, so the
75 * standard handling of these menu commands is a bit of a hack: we simply
76 * write the literal text of the command ("save", "restore", etc) into the
77 * command-line buffer, as though the player had actually typed the
78 * command, and then return the command line from os_gets(). This works
79 * fine as far as it goes, but it has one big restriction: there's no way
80 * to get these system command events from os_get_event().
81 *
82 * This function gives os_get_event() access to the system menu commands.
83 * The system commands can be enabled individually; this is important
84 * because it allows the GUI to show the commands as appropriately enabled
85 * or disabled in menus and toolbars and whatever other widgets are used.
86 * Once a command is enabled, then whenever we're blocked in a UI read in
87 * os_get_event(), the command will be shown as enabled in the visual UI;
88 * if the user then selects the command, it will be returned from
89 * os_get_event() via an OS_EVT_COMMAND event.
90 *
91 * 'id' is an OS_CMD_xxx value identifying which event is to be enabled or
92 * disabled. Once set, an event's status will remain as given until the
93 * next call to this routine with the same ID.
94 *
95 * 'status' is a combination of OS_CMDSTAT_xxx flags specifying the event's
96 * status. By default, all events are *disabled* for os_get_event(), and
97 * all events are *enabled* for os_gets(). You can control the
98 * os_get_event() and os_gets() status of the event separately. If you
99 * don't include an OS_CMDSTAT_EVT_xxx bit in the flags, the current
100 * os_get_event() status is left unchanged; likewise, if you don't include
101 * an OS_CMDSTAT_GETS_xxx bit, the os_gets() status is left unchanged.
102 */
103 void os_enable_cmd_event(int id, unsigned int status);
104
105 /* ------------------------------------------------------------------------ */
106 /*
107 * Command status codes for os_enable_cmd_event.
108 *
109 * Note that if the ENA and DIS bit for the same type are both set, the ENA
110 * takes precedence.
111 *
112 * (OS implementors: note that each ENA/DIS pair consists of a "select" bit
113 * and an "enable" bit. If the "select" bit for a pair is missing, then
114 * you don't need to update the corresponding status bit. If the "select"
115 * bit is present, then simply set the corresponding status bit to the
116 * "enable" bit value.)
117 */
118
119 /* enable/disable the event for os_get_event() */
120 #define OS_CMDSTAT_EVT_ENA (OSCS_EVT_SEL | OSCS_EVT_ON)
121 #define OS_CMDSTAT_EVT_DIS (OSCS_EVT_SEL | 0x0000)
122
123 /* enable/disable the event for os_gets() */
124 #define OS_CMDSTAT_GETS_ENA (OSCS_GETS_SEL | OSCS_GETS_ON)
125 #define OS_CMDSTAT_GETS_DIS (OSCS_GETS_SEL | 0x0000)
126
127 /* internal use: SELECT and ON bits for OS_CMDSTAT_xxx_yyy */
128 #define OSCS_EVT_SEL 0x0001
129 #define OSCS_EVT_ON 0x0002
130 #define OSCS_GTS_SEL 0x0004
131 #define OSCS_GTS_ON 0x0008
132
133
134 #endif /* OSIFCEXT_H */
135