blob: 08f0236c43abddccfaf9e8a758812175f67e4fff [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
34Note that \code{EasyDialogs} does not currently use the notification
35manager. This means that displaying dialogs while the program is in
36the background will need to unexpected results and possibly crashes.
37
38
39\section{Standard module \sectcode{FrameWork}}
40\stmodindex{FrameWork}
41
42The \code{FrameWork} module contains classes that together provide a
43framework for an interactive Macintosh application. The programmer
44builds an application by creating subclasses that override various
45methods of the bases classes, thereby implementing the functionality
46wanted. Overriding functionality can often be done on various
47different levels, i.e. to handle clicks in a single dialog window in a
48non-standard way it is not necessary to override the complete event
49handling.
50
51The \code{FrameWork} is still very much work-in-progress, and the
52documentation describes only the most important functionality, and not
53in the most logical manner at that. Examine the source for more
54esoteric needs.
55
56The \code{EasyDialogs} module defines the following functions:
57
58\renewcommand{\indexsubitem}{(in module FrameWork)}
59
60\begin{funcdesc}{Application}{}
61An object representing the complete application. See below for a
62description of the methods. The default \code{__init__} routine
63creates an empty window dictionary and a menu bar with an apple menu.
64\end{funcdesc}
65
66\begin{funcdesc}{MenuBar}{}
67An object representing the menubar. This object is usually not created
68by the user.
69\end{funcdesc}
70
71\begin{funcdesc}{Menu}{bar\, title\optional{\, after}}
72An object representing a menu. Upon creation you pass the
73\code{MenuBar} the menu appears in, the \var{title} string and a
74position (1-based) \var{after} where the menu should appear (default:
75at the end).
76\end{funcdesc}
77
78\begin{funcdesc}{MenuItem}{menu\, title\optional{\, shortcut\, callback}}
79Create a menu item object. The arguments are the menu to crate the
80item it, the item title string and optionally the keyboard shortcut
81and a callback routine. The callback is called with the arguments
82menu-id, item number within menu (1-based), current front window and
83the event record.
84\end{funcdesc}
85
86\begin{funcdesc}{Separator}{menu}
87Add a separator to the end of a menu.
88\end{funcdesc}
89
90\begin{funcdesc}{SubMenu}{menu\, label}
91Create a submenu named \var{label} under menu \var{menu}. The menu
92object is returned.
93\end{funcdesc}
94
95\begin{funcdesc}{Window}{parent}
96Creates a (modeless) window. \var{Parent} is the application object to
97which the window belongs. The window is not displayed until later.
98\end{funcdesc}
99
100\begin{funcdesc}{DialogWindow}{parent}
101Creates a modeless dialog window.
102\end{funcdesc}
103
104
105\subsection{Application objects}
106Application objects have the following methods, among others:
107
108\renewcommand{\indexsubitem}{(Application method)}
109
110\begin{funcdesc}{makeusermenus}{}
111Override this method if you need menus in your application. Append the
112menus to \code{self.menubar}.
113\end{funcdesc}
114
115\begin{funcdesc}{getabouttext}{}
116Override this method to return a text string describing your
117application. Alternatively, override the \code{do_about} method for
118more elaborate about messages.
119\end{funcdesc}
120
121\begin{funcdesc}{mainloop}{\optional{mask\, wait}}
122This routine is the main event loop, call it to set your application
123rolling. \var{Mask} is the mask of events you want to handle,
124\var{wait} is the number of ticks you want to leave to other
125concurrent application (default 0, which is probably not a good
126idea). This method does not return until \code{self} is raised.
127
128The event loop is split into many small parts, each of which can be
129overridden. The default methods take care of dispatching events to
130windows and dialogs, handling drags and resizes, Apple Events, events
131for non-FrameWork windows, etc.
132\end{funcdesc}
133
134\begin{funcdesc}{do_char}{c\, event}
135The user typed character \var{c}. The complete details of the event
136can be found in the \var{event} structure. This method can also be
137provided in a \code{Window} object, which overrides the
138application-wide handler if the window is frontmost.
139\end{funcdesc}
140
141\begin{funcdesc}{do_dialogevent}{event}
142Called early in the event loop to handle modeless dialog events. The
143default method simply dispatches the event to the relevant dialog (not
144through the the \code{DialogWindow} object involved). Override if you
145need special handling of dialog events (keyboard shortcuts, etc).
146\end{funcdesc}
147
148\subsection{Window Objects}
149
150Window objects have the following methods, among others:
151
152\renewcommand{\indexsubitem}{(Window method)}
153
154\begin{funcdesc}{open}{}
155Override this method to open a window. Store the MacOS window-id in
156\code{self.wid} and call \code{self.do_postopen} to register the
157window with the parent application.
158\end{funcdesc}
159
160\begin{funcdesc}{close}{}
161Override this method to do any special processing on window
162close. Call \code{self.do_postclose} to cleanup the parent state.
163\end{funcdesc}
164
165\begin{funcdesc}{do_postresize}{width\, height\, macoswindowid}
166Called after the window is resized. Override if more needs to be done
167than calling \code{InvalRect}.
168\end{funcdesc}
169
170\begin{funcdesc}{do_contentclick}{local\, modifiers\, event}
171The user clicked in the content part of a window. The arguments are
172the coordinates (window-relative), the key modifiers and the raw
173event.
174\end{funcdesc}
175
176\begin{funcdesc}{do_update}{macoswindowid\, event}
177An update event for the window was received. Redraw the window.
178\end{funcdesc}
179
180\begin{funcdesc}{do_activate}{activate\, event}
181The window was activated (\code{activate==1}) or deactivated
182(\code{activate==0}). Handle things like focus highlighting, etc.
183\end{funcdesc}
184
185\subsection{DialogWindow Objects}
186
187DialogWindow objects have the following methods besides those of
188\code{Window} objects:
189
190\renewcommand{\indexsubitem}{(DialogWindow method)}
191
192\begin{funcdesc}{open}{resid}
193Create the dialog window, from the DLOG resource with id
194\var{resid}. The dialog object is stored in \code{self.wid}.
195\end{funcdesc}
196
197\begin{funcdesc}{do_itemhit}{item\, event}
198Item number \var{item} was hit. You are responsible for redrawing
199toggle buttons, etc.
200\end{funcdesc}
201