| 1 | #charset "us-ascii" |
| 2 | #pragma once |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 1999, 2006 Michael J. Roberts |
| 6 | * |
| 7 | * This file is part of TADS 3 |
| 8 | * |
| 9 | * This header defines the tads-io-ext function sets, which provides |
| 10 | * optional extensions to the standard input/output set. |
| 11 | * |
| 12 | * These functions are defined in a separate function set from the basic |
| 13 | * tads-io set, because the features defined here are available only on |
| 14 | * certain platforms. Be aware that using this function set will limit |
| 15 | * your program to interpreters that support it, and will prevent your |
| 16 | * program from running on some systems. |
| 17 | */ |
| 18 | |
| 19 | |
| 20 | /* |
| 21 | * The TADS input/output extensions function set. |
| 22 | */ |
| 23 | intrinsic 'tads-io-ext/030000' |
| 24 | { |
| 25 | /* |
| 26 | * Show a popup menu. This opens a temporary window, drawn in a style |
| 27 | * consistent with the local conventions for popup menus. The new |
| 28 | * window is shown in the foreground, in front of the active game |
| 29 | * window. 'txt' gives HTML text that's used for the contents of the |
| 30 | * new window. |
| 31 | * |
| 32 | * 'x' and 'y' give the location of the top left corner of the new |
| 33 | * window. The coordinates are given in pixels relative to the top |
| 34 | * left of the game window. If these are nil (note that *both* must be |
| 35 | * nil if either one is), the popup is shown at a suitable local |
| 36 | * default position for a context menu. On Windows, the default |
| 37 | * position is the current mouse position. |
| 38 | * |
| 39 | * This function doesn't return until the user either makes a selection |
| 40 | * from the menu or cancels the menu. If the user clicks the mouse |
| 41 | * outside of the popup menu, or switches to a different window, the |
| 42 | * popup is canceled - this means that the popup menu will |
| 43 | * automatically disappear, and the function will return the 'canceled' |
| 44 | * status code. If the user makes a selection from the popup menu by |
| 45 | * clicking on a hyperlink shown within the menu, the menu disappears |
| 46 | * and the function returns the 'href' status code and the HREF text of |
| 47 | * the selected hyperlink. |
| 48 | * |
| 49 | * (Note that some systems might have different local conventions for |
| 50 | * operating a popup menu, so the actual user actions involved in |
| 51 | * selecting or canceling might differ from system to system. In these |
| 52 | * cases, the local conventions apply.) |
| 53 | * |
| 54 | * The return value is a list. The first element of the list is one of |
| 55 | * the PopMenuXxx status codes, indicating what happened. If the |
| 56 | * status code is PopMenuHRef, the list will have a second element, |
| 57 | * containing a string giving the HREF of the hyperlink the user |
| 58 | * clicked on. For any other status codes, the list will have no |
| 59 | * further elements. |
| 60 | */ |
| 61 | showPopupMenu(x, y, txt); |
| 62 | |
| 63 | /* |
| 64 | * Enable/disable a system menu command. Some interpreters offer a set |
| 65 | * of common system-level game commands via menus, toolbars, or similar |
| 66 | * UI widgets, depending on local conventions - commands such as SAVE, |
| 67 | * RESTORE, UNDO, and QUIT that most games offer. |
| 68 | * |
| 69 | * By default, when the player selects this sort of menu command, the |
| 70 | * interpreter sends it to the game by stuffing the literal text of the |
| 71 | * command into the command line, and returning it from the |
| 72 | * command-line input function (inputLine(), typically). This was |
| 73 | * traditionally the only way for the interpreter to send this sort of |
| 74 | * command to the game. In particular, there was no way to send this |
| 75 | * kind of command via the "event input" mechanism (as in |
| 76 | * inputEvent()). |
| 77 | * |
| 78 | * This function allows the game to control (1) which commands are |
| 79 | * enabled for normal command-line input, and (2) whether or not the |
| 80 | * commands are enabled for inputEvent(). By default, all commands are |
| 81 | * enabled for inputLine(), and all are disabled for inputEvent(). |
| 82 | * |
| 83 | * When a command is enabled for inputLine(), it's returned from |
| 84 | * inputLine() as the command-line string corresponding to the command. |
| 85 | * The SAVE command is returned as the text "save", for example. |
| 86 | * |
| 87 | * When a command is enabled for inputEvent(), it's returned as an |
| 88 | * InEvtSysCommand event, with the command ID in the second element of |
| 89 | * the event record's list. |
| 90 | * |
| 91 | * 'id' is the ID of the command to enable/disable, or a list or vector |
| 92 | * of IDs to set. If a list or vector is used, all of the commands |
| 93 | * listed are set to the same new status. Command IDs are given by the |
| 94 | * XxxCommand values defined in tadsio.h. |
| 95 | * |
| 96 | * 'stat' is the new status to send. This is a combination of the |
| 97 | * MenuStatXxxEnable and MenuStatXxxDisable flags defined below. For |
| 98 | * any Xxx, only one of Enable or Disable can be used - if both are |
| 99 | * specified together, the Enable flag takes precedence. If you don't |
| 100 | * specify either the Enable or Disable flag for an Xxx, then the |
| 101 | * command is unaffected in that context - that is, its previous value |
| 102 | * is left in effect. For example, if you specify MenuStatEventEnable, |
| 103 | * then the command is enabled for inputEvent(), and its previous |
| 104 | * status for inputLine() is left unchanged. |
| 105 | */ |
| 106 | enableSystemMenuCommand(id, stat); |
| 107 | } |
| 108 | |
| 109 | |
| 110 | |
| 111 | /* ------------------------------------------------------------------------ */ |
| 112 | /* |
| 113 | * showPopupMenu status codes. The function returns a list whose first |
| 114 | * element is one of these codes. |
| 115 | */ |
| 116 | |
| 117 | /* |
| 118 | * Failed: the popup menu could not be shown. This could indicate a |
| 119 | * resource problem (low memory, for example) or another system problem. |
| 120 | */ |
| 121 | #define PopMenuFail 0 |
| 122 | |
| 123 | /* |
| 124 | * HRef: the user clicked on a hyperlink shown in the menu. The list will |
| 125 | * contain a second element giving a string with the HREF of the hyperlink |
| 126 | * the user selected. |
| 127 | */ |
| 128 | #define PopMenuHRef 1 |
| 129 | |
| 130 | /* |
| 131 | * Canceled: the user canceled the menu. This usually means that the user |
| 132 | * clicked outside of the menu, or switched to a different application. |
| 133 | */ |
| 134 | #define PopMenuCancel 2 |
| 135 | |
| 136 | /* |
| 137 | * "End of file": this indicates that the application is being terminated, |
| 138 | * so it's not possible to obtain any further input from the user. |
| 139 | */ |
| 140 | #define PopMenuEof 3 |
| 141 | |
| 142 | |
| 143 | /* ------------------------------------------------------------------------ */ |
| 144 | /* |
| 145 | * enableSystemMenuCommand() status codes. You can control the inputLine() |
| 146 | * and inputEvent() status of a command independently - simply specify the |
| 147 | * flags for the context you want to change, and leave the others |
| 148 | * unspecified. |
| 149 | * |
| 150 | * MenuStatLineEnable and MenuStatLineDisable let you control the |
| 151 | * inputLine() status of a command. If neither is specified, the old |
| 152 | * status is left unchagned for inputLine(). |
| 153 | * |
| 154 | * MenuStatEventEnable and MenuStatEventDisable control the inputEvent() |
| 155 | * status of a command. If neither is specified, the old status is left |
| 156 | * unchagned for inputEvent(). |
| 157 | */ |
| 158 | #define MenuStatLineEnable (0x0004 | 0x0008) |
| 159 | #define MenuStatLineDisable (0x0004 | 0x0000) |
| 160 | |
| 161 | #define MenuStatEventEnable (0x0001 | 0x0002) |
| 162 | #define MenuStatEventDisable (0x0001 | 0x0000) |
| 163 | |
| 164 |