blob: f785679e80ea35dcf6f6d1aa1bed9c79ebd1aec7 [file] [log] [blame]
Jack Jansenda53c521995-10-10 14:43:20 +00001\section{Standard module \sectcode{EasyDialogs}}
2\stmodindex{EasyDialogs}
3
4The \code{EasyDialogs} module contains some simple dialogs for
5the Macintosh, modelled after the \code{stdwin} dialogs with similar
6names.
7
8The \code{EasyDialogs} module defines the following functions:
9
10\renewcommand{\indexsubitem}{(in module EasyDialogs)}
11
12\begin{funcdesc}{Message}{str}
13A modal dialog with the message text \var{str}, which should be at
14most 255 characters long, is displayed. Control is returned when the
15user clicks ``OK''.
16\end{funcdesc}
17
18\begin{funcdesc}{AskString}{prompt\optional{\, default}}
19Ask the user to input a string value, in a modal dialog. \var{Prompt}
20is the promt message, the optional \var{default} arg is the initial
21value for the string. All strings can be at most 255 bytes
22long. \var{AskString} returns the string entered or \code{None} in
23case the user cancelled.
24\end{funcdesc}
25
26\begin{funcdesc}{AskYesNoCancel}{question\optional{\, default}}
27Present a dialog with text \var{question} and three buttons labelled
28``yes'', ``no'' and ``cancel''. Return \code{1} for yes, \code{0} for
29no and \code{-1} for cancel. The default return value chosen by
30hitting return is \code{0}. This can be changed with the optional
31\var{default} argument.
32\end{funcdesc}
33
Jack Jansen350b2b91995-11-14 10:30:27 +000034\begin{funcdesc}{ProgressBar}{\optional{label\, maxval}}
35Display a modeless progress dialog with a thermometer bar. \var{Label}
36is the textstring displayed (default ``Working...''), \var{maxval} is
37the value at which progress is complete (default 100). The returned
38object has one method, \code{set(value)}, which sets the value of the
39progress bar. The bar remains visible until the object returned is
40discarded.
41
42The progress bar has a ``cancel'' button, but it is currently
43non-functional.
44\end{funcdesc}
45
Jack Jansenda53c521995-10-10 14:43:20 +000046Note that \code{EasyDialogs} does not currently use the notification
47manager. This means that displaying dialogs while the program is in
Jack Jansen350b2b91995-11-14 10:30:27 +000048the background will lead to unexpected results and possibly
49crashes. Also, all dialogs are modeless and hence expect to be at the
50top of the stacking order. This is true when the dialogs are created,
51but windows that pop-up later (like a console window) may also result
52in crashes.
Jack Jansenda53c521995-10-10 14:43:20 +000053
54
55\section{Standard module \sectcode{FrameWork}}
56\stmodindex{FrameWork}
57
58The \code{FrameWork} module contains classes that together provide a
59framework for an interactive Macintosh application. The programmer
60builds an application by creating subclasses that override various
61methods of the bases classes, thereby implementing the functionality
62wanted. Overriding functionality can often be done on various
63different levels, i.e. to handle clicks in a single dialog window in a
64non-standard way it is not necessary to override the complete event
65handling.
66
67The \code{FrameWork} is still very much work-in-progress, and the
68documentation describes only the most important functionality, and not
69in the most logical manner at that. Examine the source for more
70esoteric needs.
71
72The \code{EasyDialogs} module defines the following functions:
73
74\renewcommand{\indexsubitem}{(in module FrameWork)}
75
76\begin{funcdesc}{Application}{}
77An object representing the complete application. See below for a
78description of the methods. The default \code{__init__} routine
79creates an empty window dictionary and a menu bar with an apple menu.
80\end{funcdesc}
81
82\begin{funcdesc}{MenuBar}{}
83An object representing the menubar. This object is usually not created
84by the user.
85\end{funcdesc}
86
87\begin{funcdesc}{Menu}{bar\, title\optional{\, after}}
88An object representing a menu. Upon creation you pass the
89\code{MenuBar} the menu appears in, the \var{title} string and a
90position (1-based) \var{after} where the menu should appear (default:
91at the end).
92\end{funcdesc}
93
94\begin{funcdesc}{MenuItem}{menu\, title\optional{\, shortcut\, callback}}
95Create a menu item object. The arguments are the menu to crate the
96item it, the item title string and optionally the keyboard shortcut
97and a callback routine. The callback is called with the arguments
98menu-id, item number within menu (1-based), current front window and
99the event record.
100\end{funcdesc}
101
102\begin{funcdesc}{Separator}{menu}
103Add a separator to the end of a menu.
104\end{funcdesc}
105
106\begin{funcdesc}{SubMenu}{menu\, label}
107Create a submenu named \var{label} under menu \var{menu}. The menu
108object is returned.
109\end{funcdesc}
110
111\begin{funcdesc}{Window}{parent}
112Creates a (modeless) window. \var{Parent} is the application object to
113which the window belongs. The window is not displayed until later.
114\end{funcdesc}
115
116\begin{funcdesc}{DialogWindow}{parent}
117Creates a modeless dialog window.
118\end{funcdesc}
119
120
121\subsection{Application objects}
122Application objects have the following methods, among others:
123
124\renewcommand{\indexsubitem}{(Application method)}
125
126\begin{funcdesc}{makeusermenus}{}
127Override this method if you need menus in your application. Append the
128menus to \code{self.menubar}.
129\end{funcdesc}
130
131\begin{funcdesc}{getabouttext}{}
132Override this method to return a text string describing your
133application. Alternatively, override the \code{do_about} method for
134more elaborate about messages.
135\end{funcdesc}
136
137\begin{funcdesc}{mainloop}{\optional{mask\, wait}}
138This routine is the main event loop, call it to set your application
139rolling. \var{Mask} is the mask of events you want to handle,
140\var{wait} is the number of ticks you want to leave to other
141concurrent application (default 0, which is probably not a good
142idea). This method does not return until \code{self} is raised.
143
144The event loop is split into many small parts, each of which can be
145overridden. The default methods take care of dispatching events to
146windows and dialogs, handling drags and resizes, Apple Events, events
147for non-FrameWork windows, etc.
148\end{funcdesc}
149
150\begin{funcdesc}{do_char}{c\, event}
151The user typed character \var{c}. The complete details of the event
152can be found in the \var{event} structure. This method can also be
153provided in a \code{Window} object, which overrides the
154application-wide handler if the window is frontmost.
155\end{funcdesc}
156
157\begin{funcdesc}{do_dialogevent}{event}
158Called early in the event loop to handle modeless dialog events. The
159default method simply dispatches the event to the relevant dialog (not
160through the the \code{DialogWindow} object involved). Override if you
161need special handling of dialog events (keyboard shortcuts, etc).
162\end{funcdesc}
163
Jack Jansen350b2b91995-11-14 10:30:27 +0000164\begin{funcdesc}{idle}{}
165Called by the main event loop when no events are available.
166\end{funcdesc}
167
Jack Jansenda53c521995-10-10 14:43:20 +0000168\subsection{Window Objects}
169
170Window objects have the following methods, among others:
171
172\renewcommand{\indexsubitem}{(Window method)}
173
174\begin{funcdesc}{open}{}
175Override this method to open a window. Store the MacOS window-id in
176\code{self.wid} and call \code{self.do_postopen} to register the
177window with the parent application.
178\end{funcdesc}
179
180\begin{funcdesc}{close}{}
181Override this method to do any special processing on window
182close. Call \code{self.do_postclose} to cleanup the parent state.
183\end{funcdesc}
184
185\begin{funcdesc}{do_postresize}{width\, height\, macoswindowid}
186Called after the window is resized. Override if more needs to be done
187than calling \code{InvalRect}.
188\end{funcdesc}
189
190\begin{funcdesc}{do_contentclick}{local\, modifiers\, event}
191The user clicked in the content part of a window. The arguments are
192the coordinates (window-relative), the key modifiers and the raw
193event.
194\end{funcdesc}
195
196\begin{funcdesc}{do_update}{macoswindowid\, event}
197An update event for the window was received. Redraw the window.
198\end{funcdesc}
199
200\begin{funcdesc}{do_activate}{activate\, event}
201The window was activated (\code{activate==1}) or deactivated
202(\code{activate==0}). Handle things like focus highlighting, etc.
203\end{funcdesc}
204
205\subsection{DialogWindow Objects}
206
207DialogWindow objects have the following methods besides those of
208\code{Window} objects:
209
210\renewcommand{\indexsubitem}{(DialogWindow method)}
211
212\begin{funcdesc}{open}{resid}
213Create the dialog window, from the DLOG resource with id
214\var{resid}. The dialog object is stored in \code{self.wid}.
215\end{funcdesc}
216
217\begin{funcdesc}{do_itemhit}{item\, event}
218Item number \var{item} was hit. You are responsible for redrawing
219toggle buttons, etc.
220\end{funcdesc}
221