Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

610987 views
1
% This file was created automatically from usercomm.msk.
2
% DO NOT EDIT!
3
\Chapter{User Communication}
4
5
{\XGAP} has two main means to communicate with the user. The first is the
6
normal command processing: The user types commands, they are transmitted to
7
{\GAP}, are executed, and produce output, which is displayed in the command
8
window. The second is the mouse and the other parts of the graphical user
9
interface. This latter part can be divided into menus, mouse events,
10
dialogs, and popups.
11
12
\beginitems
13
Menus & Most of the windows of {\XGAP} have menus. The user can select
14
entries in them and this information is transformed to a function call in
15
{\GAP}. Menu entries can be checked or not, so menus can also display
16
information.
17
18
Mouse Events & A mouse event is the pressing or releasing of a mouse
19
button, together with the position where the mouse pointer is in the exact
20
moment this happens and the state of certain keyboard keys (mainly shift
21
and control). Such events also trigger {\GAP} function calls and the
22
corresponding functions can react on these events and for example wait for
23
others.
24
25
Dialogs & Dialogs are windows which display information and into which
26
the user can enter information for example in form of text fields.
27
28
Popups & Popups are special dialogs where the user can not type text but
29
can only click on certain buttons. {\XGAP} has so called ``text selectors''
30
which are a convenient construct to display textual information and let the
31
user select parts of it.
32
\enditems
33
34
Most of those graphical objects have corresponding {\GAP} objects, which
35
are created by constructors and can be used later on by operations.
36
37
38
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39
\Section{Menus in Graphic Sheets}
40
41
\>`Menu( <sheet>, <title>, <ents>, <fncs> )'{Menu![menu]}@{`Menu'!`[menu]'} O
42
\>`Menu( <sheet>, <title>, <zipped> )'{Menu![menu]}@{`Menu'!`[menu]'} O
43
44
`Menu' returns a pulldown menu. It is attached to the sheet <sheet>
45
under the title <title>. In the first form <ents> is a list of strings
46
consisting of the names of the menu entries. <fncs> is a list of
47
functions. They are called when the corresponding menu entry is selected
48
by the user. The parameters they get are the graphic sheet as first
49
parameter, the menu object as second, and the name of the selected entry
50
as third parameter. In the second form the entry names and functions are
51
all in one list <zipped> in alternating order, meaning first a menu entry,
52
then the corresponding function and so on.
53
Note that you can delete menus but it is not possible to modify them,
54
once they are attached to the sheet.
55
If a name of a menu entry begins with a minus sign or the list entry
56
in <ents> is not bound, a dummy menu entry is generated, which can sort
57
the menu entries within a menu in blocks. The corresponding function
58
does not matter.
59
60
61
\>Check( <menu>, <entry>, <flag> ) O
62
63
Modifies the ``checked'' state of a menu entry. This is visualized by a
64
small check mark behind the menu entry. <menu> must be a menu object,
65
<entry> the string exactly as in the definition of the menu, and <flag>
66
a boolean value.
67
68
69
\>Enable( <menu>, <entry>, <flag> ) O
70
\>Enable( <menu>, <boollist> ) O
71
72
Modifies the ``enabled'' state of a menu entries. Only enabled menu entries
73
can be selected by the user. Disabled menu entries are visualized
74
by grey or shaded letters in the menu. <menu> must be a menu object,
75
<entry> the string exactly as in the definition of the menu, and <flag>
76
a boolean value. <entry> can also be a natural number meaning the index
77
of the corresponding menu entry.
78
In the second form <boollist> must be a list where each
79
entry has either a boolean value or the value `fail'
80
The list must be as long as the
81
number of menu entries in the menu <menu>. All menu entries where a
82
boolean value is provided are enabled or disabled according to this
83
value.
84
85
86
87
See the explanation of `GraphicSheet' ("Close!Callback") for the ``Close''
88
event, which occurs when the user selects the menu entry
89
`close graphic sheet' in the `Sheet' menu.
90
91
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92
\Section{Mouse Events}
93
94
When a mouse event occurs, this is communicated to {\GAP} via a function
95
call which in turn triggers a callback. As described in "GraphicSheet" to
96
"CtrlRightPBDown" the following callback keys are predefined as reactions
97
on mouse events: `LeftPBDown', `RightPBDown', `ShiftLeftPBDown',
98
`ShiftRightPBDown', `CtrlLeftPBDown', `CtrlRightPBDown'.
99
100
Note that when your function gets called, the mouse button will still be
101
pressed. So it can react and for example wait for the release. There is an
102
easy way to find out about the state of the mouse buttons after the event:
103
104
\>WcQueryPointer( <id> ) F
105
106
<id> must be a `WindowId' of an {\XGAP} sheet. This function returns a
107
vector of four integers. The first two are the coordinates of the mouse
108
pointer relative to the {\XGAP} sheet. Values outside the window are
109
represented by $-1$. The third element is a number where the pressed
110
buttons are coded. If no mouse button is pressed, the value is zero.
111
`BUTTONS.left' is added to the value, if the left mouse button is pressed
112
and `BUTTONS.right' is added, if the right mouse button is pressed. The
113
fourth value codes the state of the shift and control. Here the values
114
`BUTTONS.shift' and `BUTTONS.ctrl' are used.
115
116
117
118
This function is used in
119
120
\>Drag( <sheet>, <x>, <y>, <bt>, <func> ) O
121
122
Call this function when a button event has occurred, so the button <bt>
123
is still pressed. It waits until the user releases the mouse button and
124
calls <func> for every change of the mouse position with the new x and
125
y position as two integer parameters. You can implement a dragging
126
procedure in this way as in the following example: (we assume that a
127
`LeftPBDown' event just occurred and x and y contain the current mouse
128
pointer position):
129
130
\begintt
131
storex := x;
132
storey := y;
133
box := Rectangle(sheet,x,y,0,0);
134
if Drag(sheet,x,y,BUTTONS.left,
135
function(x,y)
136
local bx,by,bw,bh;
137
if x < storex then
138
bx := x;
139
bw := storex - x;
140
else
141
bx := storex;
142
bw := x - storex;
143
fi;
144
if y < storey then
145
by := y;
146
bh := storey - y;
147
else
148
by := storey;
149
bh := y - storey;
150
fi;
151
if bx <> box!.x or by <> box!.y then
152
Move(box,bx,by);
153
fi;
154
if bw <> box!.w or bh <> box!.h then
155
Reshape(box,bw,bh);
156
fi;
157
end) then
158
the box had at one time at least a certain size
159
... work with box ...
160
else
161
the box was never big enough, we do nothing
162
fi;
163
Delete(box);
164
\endtt
165
166
167
168
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
\Section{Dialogs}
170
171
\>Dialog( <type>, <text> ) O
172
173
creates a dialog box and returns a {\GAP} object describing it. There are
174
currently two types of dialogs: A file selector dialog (called
175
`Filename') and a dialog type called `OKcancel'. <text> is a text that
176
appears as a title in the dialog box.
177
178
179
180
\>Query( <obj> ) O
181
\>Query( <obj>, <default> ) O
182
183
Puts a dialog on screen. Returns `false' if the user clicks ``Cancel'' and
184
a string value or filename, if the user clicks ``OK'', depending on the
185
type of dialog. <default> is an optional initialization value for the
186
string.
187
188
189
190
%Puts a dialog on screen. Returns `false' if the user clicks ``Cancel'' and
191
%a string value or filename, if the user clicks ``OK'', depending on the
192
%type of dialog. <default> is an optional initialization value for the string.
193
194
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195
\Section{Popups}
196
197
\>PopupMenu( <name>, <labels> ) O
198
199
creates a new popup menu and returns a {\GAP} object describing it.
200
<name> is the title of the menu and <labels> is a list of strings for
201
the entries. Use `Query' to actually put the popup on the screen.
202
203
204
205
\>`Query'{Query!for popup}@{`Query'!for popup}
206
207
actually puts a popup on screen. `Query' returns the string of the
208
selected entry or `false' if the user clicks outside the popup.
209
See also `Query' for dialogs in "Query".
210
211
\>TextSelector( <name>, <list>, <buttons> ) O
212
213
creates a new text selector and returns a {\GAP} object describing it.
214
<name> is a title. <list> is an alternating list of strings and
215
functions. The strings are displayed and can be selected by the user.
216
If this happens the corresponding function is called with two
217
parameters. The first is the text selector object itself, the second
218
the string that is selected. A selected string is highlighted and all
219
other strings are reset at the same time. Use `Reset' to reset all
220
entries.
221
222
<buttons> is an analogous list for the buttons that are
223
displayed at the bottom of the text selector. The text selector is
224
displayed immediately and stays on screen until it is closed (use the
225
`Close' operation). Buttons can be enabled and disabled by the `Enable'
226
operation and the string of a text can be changed via `Relabel'.
227
228
229
230
\>Enable( <sel>,<bt>,<flag> )!{for text selectors}
231
\>Enable( <sel>,<btindex>,<flag> )!{for text selectors}
232
233
Enables or disables the button <bt> (string value) or <btindex>
234
(integer index) of the text selector <sel>, according to <flag>.
235
236
\>Relabel( <sel>, <list> )!{for text selectors}
237
\>Relabel( <sel>, <index>, <text> )!{for text selectors}
238
239
Changes the strings that are displayed in the text selector. In the
240
first form <list> must be a list of strings. The second form only
241
changes the text at index <index>.
242
243
\>SetName( <sel>, <index>, <string> )!{for text selectors}
244
245
Every string in a text selector has a name. The names are stored in
246
the list `names' component of the text selector. So `sel!.names' ist a
247
list containing the names. The names are initialized with the strings
248
from the creation of the text selector.
249
250
\>Reset( <sel> )!{for text selectors}
251
252
Resets all strings of a text selector, such that they are no longer
253
selected.
254
255
\>Close( <sel> )!{for text selectors}
256
257
Closes a text selector. It vanishes from screen.
258
259
Note that you have access to the indices and names of strings and
260
buttons:
261
262
\>`IndexOfSelectedText'{IndexOfSelectedText}@{`IndexOfSelectedText'}
263
264
Whenever the user clicks on a text in a text selector, the global
265
variable is set to the index of the text in the text
266
selector.
267
268
\>`IndexOfSelectedButton'{IndexOfSelectedButton}@{`IndexOfSelectedButton'}
269
270
Whenever the user clicks on a button in a text selector, the global
271
variable is set to the index of the button in the text selector.
272
273