cfad47cfa3/t3compiler/tads3/include/tadsiox.h

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