blob: 47f10c737e23715972ed05ec76af8cbe814e50e2 [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Built-in Module \sectcode{fl}}
2\bimodindex{fl}
3
4This module provides an interface to the FORMS Library by Mark
Guido van Rossum470be141995-03-17 16:07:09 +00005Overmars. The source for the library can be retrieved by anonymous
6ftp from host \samp{ftp.cs.ruu.nl}, directory \file{SGI/FORMS}. It
7was last tested with version 2.0b.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00008
9Most functions are literal translations of their C equivalents,
Guido van Rossum470be141995-03-17 16:07:09 +000010dropping the initial \samp{fl_} from their name. Constants used by
11the library are defined in module \code{FL} described below.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000012
13The creation of objects is a little different in Python than in C:
14instead of the `current form' maintained by the library to which new
15FORMS objects are added, all functions that add a FORMS object to a
Guido van Rossum470be141995-03-17 16:07:09 +000016form are methods of the Python object representing the form.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000017Consequently, there are no Python equivalents for the C functions
18\code{fl_addto_form} and \code{fl_end_form}, and the equivalent of
19\code{fl_bgn_form} is called \code{fl.make_form}.
20
21Watch out for the somewhat confusing terminology: FORMS uses the word
22\dfn{object} for the buttons, sliders etc. that you can place in a form.
23In Python, `object' means any value. The Python interface to FORMS
24introduces two new Python object types: form objects (representing an
25entire form) and FORMS objects (representing one button, slider etc.).
26Hopefully this isn't too confusing...
27
28There are no `free objects' in the Python interface to FORMS, nor is
29there an easy way to add object classes written in Python. The FORMS
Guido van Rossum470be141995-03-17 16:07:09 +000030interface to GL event handling is available, though, so you can mix
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000031FORMS with pure GL windows.
32
33\strong{Please note:} importing \code{fl} implies a call to the GL function
34\code{foreground()} and to the FORMS routine \code{fl_init()}.
35
Guido van Rossum470be141995-03-17 16:07:09 +000036\subsection{Functions Defined in Module \sectcode{fl}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000037
38Module \code{fl} defines the following functions. For more information
39about what they do, see the description of the equivalent C function
40in the FORMS documentation:
41
42\renewcommand{\indexsubitem}{(in module fl)}
43\begin{funcdesc}{make_form}{type\, width\, height}
44Create a form with given type, width and height. This returns a
45\dfn{form} object, whose methods are described below.
46\end{funcdesc}
47
48\begin{funcdesc}{do_forms}{}
49The standard FORMS main loop. Returns a Python object representing
50the FORMS object needing interaction, or the special value
51\code{FL.EVENT}.
52\end{funcdesc}
53
54\begin{funcdesc}{check_forms}{}
55Check for FORMS events. Returns what \code{do_forms} above returns,
56or \code{None} if there is no event that immediately needs
57interaction.
58\end{funcdesc}
59
60\begin{funcdesc}{set_event_call_back}{function}
61Set the event callback function.
62\end{funcdesc}
63
64\begin{funcdesc}{set_graphics_mode}{rgbmode\, doublebuffering}
65Set the graphics modes.
66\end{funcdesc}
67
68\begin{funcdesc}{get_rgbmode}{}
69Return the current rgb mode. This is the value of the C global
70variable \code{fl_rgbmode}.
71\end{funcdesc}
72
73\begin{funcdesc}{show_message}{str1\, str2\, str3}
74Show a dialog box with a three-line message and an OK button.
75\end{funcdesc}
76
77\begin{funcdesc}{show_question}{str1\, str2\, str3}
78Show a dialog box with a three-line message and YES and NO buttons.
79It returns \code{1} if the user pressed YES, \code{0} if NO.
80\end{funcdesc}
81
Guido van Rossum16d6e711994-08-08 12:30:22 +000082\begin{funcdesc}{show_choice}{str1\, str2\, str3\, but1\optional{\, but2\,
83but3}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000084Show a dialog box with a three-line message and up to three buttons.
85It returns the number of the button clicked by the user
86(\code{1}, \code{2} or \code{3}).
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000087\end{funcdesc}
88
89\begin{funcdesc}{show_input}{prompt\, default}
90Show a dialog box with a one-line prompt message and text field in
91which the user can enter a string. The second argument is the default
92input string. It returns the string value as edited by the user.
93\end{funcdesc}
94
95\begin{funcdesc}{show_file_selector}{message\, directory\, pattern\, default}
Guido van Rossum470be141995-03-17 16:07:09 +000096Show a dialog box in which the user can select a file. It returns
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000097the absolute filename selected by the user, or \code{None} if the user
98presses Cancel.
99\end{funcdesc}
100
101\begin{funcdesc}{get_directory}{}
102\funcline{get_pattern}{}
103\funcline{get_filename}{}
104These functions return the directory, pattern and filename (the tail
105part only) selected by the user in the last \code{show_file_selector}
106call.
107\end{funcdesc}
108
109\begin{funcdesc}{qdevice}{dev}
110\funcline{unqdevice}{dev}
111\funcline{isqueued}{dev}
112\funcline{qtest}{}
113\funcline{qread}{}
114%\funcline{blkqread}{?}
115\funcline{qreset}{}
116\funcline{qenter}{dev\, val}
117\funcline{get_mouse}{}
118\funcline{tie}{button\, valuator1\, valuator2}
119These functions are the FORMS interfaces to the corresponding GL
120functions. Use these if you want to handle some GL events yourself
121when using \code{fl.do_events}. When a GL event is detected that
122FORMS cannot handle, \code{fl.do_forms()} returns the special value
123\code{FL.EVENT} and you should call \code{fl.qread()} to read the
124event from the queue. Don't use the equivalent GL functions!
125\end{funcdesc}
126
127\begin{funcdesc}{color}{}
128\funcline{mapcolor}{}
129\funcline{getmcolor}{}
130See the description in the FORMS documentation of \code{fl_color},
131\code{fl_mapcolor} and \code{fl_getmcolor}.
132\end{funcdesc}
133
Guido van Rossum470be141995-03-17 16:07:09 +0000134\subsection{Form Objects}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000135
136Form objects (returned by \code{fl.make_form()} above) have the
137following methods. Each method corresponds to a C function whose name
138is prefixed with \samp{fl_}; and whose first argument is a form
139pointer; please refer to the official FORMS documentation for
140descriptions.
141
142All the \samp{add_{\rm \ldots}} functions return a Python object representing
143the FORMS object. Methods of FORMS objects are described below. Most
144kinds of FORMS object also have some methods specific to that kind;
145these methods are listed here.
146
147\begin{flushleft}
148\renewcommand{\indexsubitem}{(form object method)}
149\begin{funcdesc}{show_form}{placement\, bordertype\, name}
150 Show the form.
151\end{funcdesc}
152
153\begin{funcdesc}{hide_form}{}
154 Hide the form.
155\end{funcdesc}
156
157\begin{funcdesc}{redraw_form}{}
158 Redraw the form.
159\end{funcdesc}
160
161\begin{funcdesc}{set_form_position}{x\, y}
162Set the form's position.
163\end{funcdesc}
164
165\begin{funcdesc}{freeze_form}{}
166Freeze the form.
167\end{funcdesc}
168
169\begin{funcdesc}{unfreeze_form}{}
170 Unfreeze the form.
171\end{funcdesc}
172
173\begin{funcdesc}{activate_form}{}
174 Activate the form.
175\end{funcdesc}
176
177\begin{funcdesc}{deactivate_form}{}
178 Deactivate the form.
179\end{funcdesc}
180
181\begin{funcdesc}{bgn_group}{}
182 Begin a new group of objects; return a group object.
183\end{funcdesc}
184
185\begin{funcdesc}{end_group}{}
186 End the current group of objects.
187\end{funcdesc}
188
189\begin{funcdesc}{find_first}{}
190 Find the first object in the form.
191\end{funcdesc}
192
193\begin{funcdesc}{find_last}{}
194 Find the last object in the form.
195\end{funcdesc}
196
197%---
198
199\begin{funcdesc}{add_box}{type\, x\, y\, w\, h\, name}
200Add a box object to the form.
201No extra methods.
202\end{funcdesc}
203
204\begin{funcdesc}{add_text}{type\, x\, y\, w\, h\, name}
205Add a text object to the form.
206No extra methods.
207\end{funcdesc}
208
209%\begin{funcdesc}{add_bitmap}{type\, x\, y\, w\, h\, name}
210%Add a bitmap object to the form.
211%\end{funcdesc}
212
213\begin{funcdesc}{add_clock}{type\, x\, y\, w\, h\, name}
214Add a clock object to the form. \\
215Method:
216\code{get_clock}.
217\end{funcdesc}
218
219%---
220
221\begin{funcdesc}{add_button}{type\, x\, y\, w\, h\, name}
222Add a button object to the form. \\
223Methods:
224\code{get_button},
225\code{set_button}.
226\end{funcdesc}
227
228\begin{funcdesc}{add_lightbutton}{type\, x\, y\, w\, h\, name}
229Add a lightbutton object to the form. \\
230Methods:
231\code{get_button},
232\code{set_button}.
233\end{funcdesc}
234
235\begin{funcdesc}{add_roundbutton}{type\, x\, y\, w\, h\, name}
236Add a roundbutton object to the form. \\
237Methods:
238\code{get_button},
239\code{set_button}.
240\end{funcdesc}
241
242%---
243
244\begin{funcdesc}{add_slider}{type\, x\, y\, w\, h\, name}
245Add a slider object to the form. \\
246Methods:
247\code{set_slider_value},
248\code{get_slider_value},
249\code{set_slider_bounds},
250\code{get_slider_bounds},
251\code{set_slider_return},
252\code{set_slider_size},
253\code{set_slider_precision},
254\code{set_slider_step}.
255\end{funcdesc}
256
257\begin{funcdesc}{add_valslider}{type\, x\, y\, w\, h\, name}
258Add a valslider object to the form. \\
259Methods:
260\code{set_slider_value},
261\code{get_slider_value},
262\code{set_slider_bounds},
263\code{get_slider_bounds},
264\code{set_slider_return},
265\code{set_slider_size},
266\code{set_slider_precision},
267\code{set_slider_step}.
268\end{funcdesc}
269
270\begin{funcdesc}{add_dial}{type\, x\, y\, w\, h\, name}
271Add a dial object to the form. \\
272Methods:
273\code{set_dial_value},
274\code{get_dial_value},
275\code{set_dial_bounds},
276\code{get_dial_bounds}.
277\end{funcdesc}
278
279\begin{funcdesc}{add_positioner}{type\, x\, y\, w\, h\, name}
280Add a positioner object to the form. \\
281Methods:
282\code{set_positioner_xvalue},
283\code{set_positioner_yvalue},
284\code{set_positioner_xbounds},
285\code{set_positioner_ybounds},
286\code{get_positioner_xvalue},
287\code{get_positioner_yvalue},
288\code{get_positioner_xbounds},
289\code{get_positioner_ybounds}.
290\end{funcdesc}
291
292\begin{funcdesc}{add_counter}{type\, x\, y\, w\, h\, name}
293Add a counter object to the form. \\
294Methods:
295\code{set_counter_value},
296\code{get_counter_value},
297\code{set_counter_bounds},
298\code{set_counter_step},
299\code{set_counter_precision},
300\code{set_counter_return}.
301\end{funcdesc}
302
303%---
304
305\begin{funcdesc}{add_input}{type\, x\, y\, w\, h\, name}
306Add a input object to the form. \\
307Methods:
308\code{set_input},
309\code{get_input},
310\code{set_input_color},
311\code{set_input_return}.
312\end{funcdesc}
313
314%---
315
316\begin{funcdesc}{add_menu}{type\, x\, y\, w\, h\, name}
317Add a menu object to the form. \\
318Methods:
319\code{set_menu},
320\code{get_menu},
321\code{addto_menu}.
322\end{funcdesc}
323
324\begin{funcdesc}{add_choice}{type\, x\, y\, w\, h\, name}
325Add a choice object to the form. \\
326Methods:
327\code{set_choice},
328\code{get_choice},
329\code{clear_choice},
330\code{addto_choice},
331\code{replace_choice},
332\code{delete_choice},
333\code{get_choice_text},
334\code{set_choice_fontsize},
335\code{set_choice_fontstyle}.
336\end{funcdesc}
337
338\begin{funcdesc}{add_browser}{type\, x\, y\, w\, h\, name}
339Add a browser object to the form. \\
340Methods:
341\code{set_browser_topline},
342\code{clear_browser},
343\code{add_browser_line},
344\code{addto_browser},
345\code{insert_browser_line},
346\code{delete_browser_line},
347\code{replace_browser_line},
348\code{get_browser_line},
349\code{load_browser},
350\code{get_browser_maxline},
351\code{select_browser_line},
352\code{deselect_browser_line},
353\code{deselect_browser},
354\code{isselected_browser_line},
355\code{get_browser},
356\code{set_browser_fontsize},
357\code{set_browser_fontstyle},
358\code{set_browser_specialkey}.
359\end{funcdesc}
360
361%---
362
363\begin{funcdesc}{add_timer}{type\, x\, y\, w\, h\, name}
364Add a timer object to the form. \\
365Methods:
366\code{set_timer},
367\code{get_timer}.
368\end{funcdesc}
369\end{flushleft}
370
371Form objects have the following data attributes; see the FORMS
372documentation:
373
374\begin{tableiii}{|l|c|l|}{code}{Name}{Type}{Meaning}
375 \lineiii{window}{int (read-only)}{GL window id}
376 \lineiii{w}{float}{form width}
377 \lineiii{h}{float}{form height}
378 \lineiii{x}{float}{form x origin}
379 \lineiii{y}{float}{form y origin}
380 \lineiii{deactivated}{int}{nonzero if form is deactivated}
381 \lineiii{visible}{int}{nonzero if form is visible}
382 \lineiii{frozen}{int}{nonzero if form is frozen}
383 \lineiii{doublebuf}{int}{nonzero if double buffering on}
384\end{tableiii}
385
Guido van Rossum470be141995-03-17 16:07:09 +0000386\subsection{FORMS Objects}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000387
388Besides methods specific to particular kinds of FORMS objects, all
389FORMS objects also have the following methods:
390
391\renewcommand{\indexsubitem}{(FORMS object method)}
392\begin{funcdesc}{set_call_back}{function\, argument}
393Set the object's callback function and argument. When the object
394needs interaction, the callback function will be called with two
395arguments: the object, and the callback argument. (FORMS objects
396without a callback function are returned by \code{fl.do_forms()} or
397\code{fl.check_forms()} when they need interaction.) Call this method
398without arguments to remove the callback function.
399\end{funcdesc}
400
401\begin{funcdesc}{delete_object}{}
402 Delete the object.
403\end{funcdesc}
404
405\begin{funcdesc}{show_object}{}
406 Show the object.
407\end{funcdesc}
408
409\begin{funcdesc}{hide_object}{}
410 Hide the object.
411\end{funcdesc}
412
413\begin{funcdesc}{redraw_object}{}
414 Redraw the object.
415\end{funcdesc}
416
417\begin{funcdesc}{freeze_object}{}
418 Freeze the object.
419\end{funcdesc}
420
421\begin{funcdesc}{unfreeze_object}{}
422 Unfreeze the object.
423\end{funcdesc}
424
425%\begin{funcdesc}{handle_object}{} XXX
426%\end{funcdesc}
427
428%\begin{funcdesc}{handle_object_direct}{} XXX
429%\end{funcdesc}
430
431FORMS objects have these data attributes; see the FORMS documentation:
432
433\begin{tableiii}{|l|c|l|}{code}{Name}{Type}{Meaning}
434 \lineiii{objclass}{int (read-only)}{object class}
435 \lineiii{type}{int (read-only)}{object type}
436 \lineiii{boxtype}{int}{box type}
437 \lineiii{x}{float}{x origin}
438 \lineiii{y}{float}{y origin}
439 \lineiii{w}{float}{width}
440 \lineiii{h}{float}{height}
441 \lineiii{col1}{int}{primary color}
442 \lineiii{col2}{int}{secondary color}
443 \lineiii{align}{int}{alignment}
444 \lineiii{lcol}{int}{label color}
445 \lineiii{lsize}{float}{label font size}
446 \lineiii{label}{string}{label string}
447 \lineiii{lstyle}{int}{label style}
448 \lineiii{pushed}{int (read-only)}{(see FORMS docs)}
449 \lineiii{focus}{int (read-only)}{(see FORMS docs)}
450 \lineiii{belowmouse}{int (read-only)}{(see FORMS docs)}
451 \lineiii{frozen}{int (read-only)}{(see FORMS docs)}
452 \lineiii{active}{int (read-only)}{(see FORMS docs)}
453 \lineiii{input}{int (read-only)}{(see FORMS docs)}
454 \lineiii{visible}{int (read-only)}{(see FORMS docs)}
455 \lineiii{radio}{int (read-only)}{(see FORMS docs)}
456 \lineiii{automatic}{int (read-only)}{(see FORMS docs)}
457\end{tableiii}
458
459\section{Standard Module \sectcode{FL}}
460\nodename{FL (uppercase)}
461\stmodindex{FL}
462
463This module defines symbolic constants needed to use the built-in
464module \code{fl} (see above); they are equivalent to those defined in
465the C header file \file{<forms.h>} except that the name prefix
466\samp{FL_} is omitted. Read the module source for a complete list of
467the defined names. Suggested use:
468
469\bcode\begin{verbatim}
470import fl
471from FL import *
472\end{verbatim}\ecode
473
474\section{Standard Module \sectcode{flp}}
475\stmodindex{flp}
476
477This module defines functions that can read form definitions created
478by the `form designer' (\code{fdesign}) program that comes with the
479FORMS library (see module \code{fl} above).
480
481For now, see the file \file{flp.doc} in the Python library source
482directory for a description.
483
484XXX A complete description should be inserted here!