Fred Drake | c817e27 | 1998-08-10 18:40:22 +0000 | [diff] [blame] | 1 | \section{\module{FrameWork} --- |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 2 | Interactive application framework} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 3 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{FrameWork} |
| 5 | \platform{Mac} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 6 | \modulesynopsis{Interactive application framework.} |
| 7 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 8 | |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 9 | The \module{FrameWork} module contains classes that together provide a |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 10 | framework for an interactive Macintosh application. The programmer |
| 11 | builds an application by creating subclasses that override various |
| 12 | methods of the bases classes, thereby implementing the functionality |
| 13 | wanted. Overriding functionality can often be done on various |
| 14 | different levels, i.e. to handle clicks in a single dialog window in a |
| 15 | non-standard way it is not necessary to override the complete event |
| 16 | handling. |
| 17 | |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 18 | The \module{FrameWork} is still very much work-in-progress, and the |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 19 | documentation describes only the most important functionality, and not |
| 20 | in the most logical manner at that. Examine the source or the examples |
Fred Drake | 658865c | 2000-10-14 04:53:31 +0000 | [diff] [blame] | 21 | for more details. The following are some comments posted on the |
| 22 | MacPython newsgroup about the strengths and limitations of |
| 23 | \module{FrameWork}: |
| 24 | |
| 25 | \begin{quotation} |
| 26 | The strong point of \module{FrameWork} is that it allows you to break |
| 27 | into the control-flow at many different places. \refmodule{W}, for |
| 28 | instance, uses a different way to enable/disable menus and that plugs |
| 29 | right in leaving the rest intact. The weak points of |
| 30 | \module{FrameWork} are that it has no abstract command interface (but |
| 31 | that shouldn't be difficult), that it's dialog support is minimal and |
| 32 | that it's control/toolbar support is non-existent. |
| 33 | \end{quotation} |
| 34 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 35 | |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 36 | The \module{FrameWork} module defines the following functions: |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 37 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 38 | |
| 39 | \begin{funcdesc}{Application}{} |
| 40 | An object representing the complete application. See below for a |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 41 | description of the methods. The default \method{__init__()} routine |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 42 | creates an empty window dictionary and a menu bar with an apple menu. |
| 43 | \end{funcdesc} |
| 44 | |
| 45 | \begin{funcdesc}{MenuBar}{} |
| 46 | An object representing the menubar. This object is usually not created |
| 47 | by the user. |
| 48 | \end{funcdesc} |
| 49 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 50 | \begin{funcdesc}{Menu}{bar, title\optional{, after}} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 51 | An object representing a menu. Upon creation you pass the |
| 52 | \code{MenuBar} the menu appears in, the \var{title} string and a |
| 53 | position (1-based) \var{after} where the menu should appear (default: |
| 54 | at the end). |
| 55 | \end{funcdesc} |
| 56 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 57 | \begin{funcdesc}{MenuItem}{menu, title\optional{, shortcut, callback}} |
Fred Drake | 658865c | 2000-10-14 04:53:31 +0000 | [diff] [blame] | 58 | Create a menu item object. The arguments are the menu to create, the |
| 59 | item item title string and optionally the keyboard shortcut |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 60 | and a callback routine. The callback is called with the arguments |
| 61 | menu-id, item number within menu (1-based), current front window and |
| 62 | the event record. |
| 63 | |
Fred Drake | 658865c | 2000-10-14 04:53:31 +0000 | [diff] [blame] | 64 | Instead of a callable object the callback can also be a string. In |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 65 | this case menu selection causes the lookup of a method in the topmost |
| 66 | window and the application. The method name is the callback string |
| 67 | with \code{'domenu_'} prepended. |
| 68 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 69 | Calling the \code{MenuBar} \method{fixmenudimstate()} method sets the |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 70 | correct dimming for all menu items based on the current front window. |
| 71 | \end{funcdesc} |
| 72 | |
| 73 | \begin{funcdesc}{Separator}{menu} |
| 74 | Add a separator to the end of a menu. |
| 75 | \end{funcdesc} |
| 76 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 77 | \begin{funcdesc}{SubMenu}{menu, label} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 78 | Create a submenu named \var{label} under menu \var{menu}. The menu |
| 79 | object is returned. |
| 80 | \end{funcdesc} |
| 81 | |
| 82 | \begin{funcdesc}{Window}{parent} |
| 83 | Creates a (modeless) window. \var{Parent} is the application object to |
| 84 | which the window belongs. The window is not displayed until later. |
| 85 | \end{funcdesc} |
| 86 | |
| 87 | \begin{funcdesc}{DialogWindow}{parent} |
| 88 | Creates a modeless dialog window. |
| 89 | \end{funcdesc} |
| 90 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 91 | \begin{funcdesc}{windowbounds}{width, height} |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 92 | Return a \code{(\var{left}, \var{top}, \var{right}, \var{bottom})} |
| 93 | tuple suitable for creation of a window of given width and height. The |
| 94 | window will be staggered with respect to previous windows, and an |
Fred Drake | 658865c | 2000-10-14 04:53:31 +0000 | [diff] [blame] | 95 | attempt is made to keep the whole window on-screen. However, the window will |
| 96 | however always be the exact size given, so parts may be offscreen. |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 97 | \end{funcdesc} |
| 98 | |
| 99 | \begin{funcdesc}{setwatchcursor}{} |
| 100 | Set the mouse cursor to a watch. |
| 101 | \end{funcdesc} |
| 102 | |
| 103 | \begin{funcdesc}{setarrowcursor}{} |
| 104 | Set the mouse cursor to an arrow. |
| 105 | \end{funcdesc} |
| 106 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 107 | |
| 108 | \subsection{Application Objects \label{application-objects}} |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 109 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 110 | Application objects have the following methods, among others: |
| 111 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 112 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 113 | \begin{methoddesc}[Application]{makeusermenus}{} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 114 | Override this method if you need menus in your application. Append the |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 115 | menus to the attribute \member{menubar}. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 116 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 117 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 118 | \begin{methoddesc}[Application]{getabouttext}{} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 119 | Override this method to return a text string describing your |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 120 | application. Alternatively, override the \method{do_about()} method |
| 121 | for more elaborate ``about'' messages. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 122 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 123 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 124 | \begin{methoddesc}[Application]{mainloop}{\optional{mask\optional{, wait}}} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 125 | This routine is the main event loop, call it to set your application |
| 126 | rolling. \var{Mask} is the mask of events you want to handle, |
| 127 | \var{wait} is the number of ticks you want to leave to other |
| 128 | concurrent application (default 0, which is probably not a good |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 129 | idea). While raising \var{self} to exit the mainloop is still |
| 130 | supported it is not recommended: call \code{self._quit()} instead. |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 131 | |
| 132 | The event loop is split into many small parts, each of which can be |
| 133 | overridden. The default methods take care of dispatching events to |
| 134 | windows and dialogs, handling drags and resizes, Apple Events, events |
| 135 | for non-FrameWork windows, etc. |
| 136 | |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 137 | In general, all event handlers should return \code{1} if the event is fully |
| 138 | handled and \code{0} otherwise (because the front window was not a FrameWork |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 139 | window, for instance). This is needed so that update events and such |
| 140 | can be passed on to other windows like the Sioux console window. |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 141 | Calling \function{MacOS.HandleEvent()} is not allowed within |
| 142 | \var{our_dispatch} or its callees, since this may result in an |
| 143 | infinite loop if the code is called through the Python inner-loop |
| 144 | event handler. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 145 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 146 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 147 | \begin{methoddesc}[Application]{asyncevents}{onoff} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 148 | Call this method with a nonzero parameter to enable |
| 149 | asynchronous event handling. This will tell the inner interpreter loop |
| 150 | to call the application event handler \var{async_dispatch} whenever events |
| 151 | are available. This will cause FrameWork window updates and the user |
| 152 | interface to remain working during long computations, but will slow the |
| 153 | interpreter down and may cause surprising results in non-reentrant code |
| 154 | (such as FrameWork itself). By default \var{async_dispatch} will immedeately |
| 155 | call \var{our_dispatch} but you may override this to handle only certain |
| 156 | events asynchronously. Events you do not handle will be passed to Sioux |
| 157 | and such. |
| 158 | |
| 159 | The old on/off value is returned. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 160 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 161 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 162 | \begin{methoddesc}[Application]{_quit}{} |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 163 | Terminate the running \method{mainloop()} call at the next convenient |
| 164 | moment. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 165 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 166 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 167 | \begin{methoddesc}[Application]{do_char}{c, event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 168 | The user typed character \var{c}. The complete details of the event |
| 169 | can be found in the \var{event} structure. This method can also be |
| 170 | provided in a \code{Window} object, which overrides the |
| 171 | application-wide handler if the window is frontmost. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 172 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 173 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 174 | \begin{methoddesc}[Application]{do_dialogevent}{event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 175 | Called early in the event loop to handle modeless dialog events. The |
| 176 | default method simply dispatches the event to the relevant dialog (not |
| 177 | through the the \code{DialogWindow} object involved). Override if you |
| 178 | need special handling of dialog events (keyboard shortcuts, etc). |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 179 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 180 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 181 | \begin{methoddesc}[Application]{idle}{event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 182 | Called by the main event loop when no events are available. The |
| 183 | null-event is passed (so you can look at mouse position, etc). |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 184 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 185 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 186 | |
| 187 | \subsection{Window Objects \label{window-objects}} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 188 | |
| 189 | Window objects have the following methods, among others: |
| 190 | |
| 191 | \setindexsubitem{(Window method)} |
| 192 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 193 | \begin{methoddesc}[Window]{open}{} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 194 | Override this method to open a window. Store the MacOS window-id in |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 195 | \member{self.wid} and call the \method{do_postopen()} method to |
| 196 | register the window with the parent application. |
| 197 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 198 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 199 | \begin{methoddesc}[Window]{close}{} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 200 | Override this method to do any special processing on window |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 201 | close. Call the \method{do_postclose()} method to cleanup the parent |
| 202 | state. |
| 203 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 204 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 205 | \begin{methoddesc}[Window]{do_postresize}{width, height, macoswindowid} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 206 | Called after the window is resized. Override if more needs to be done |
| 207 | than calling \code{InvalRect}. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 208 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 209 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 210 | \begin{methoddesc}[Window]{do_contentclick}{local, modifiers, event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 211 | The user clicked in the content part of a window. The arguments are |
| 212 | the coordinates (window-relative), the key modifiers and the raw |
| 213 | event. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 214 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 215 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 216 | \begin{methoddesc}[Window]{do_update}{macoswindowid, event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 217 | An update event for the window was received. Redraw the window. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 218 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 219 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 220 | \begin{methoddesc}{do_activate}{activate, event} |
| 221 | The window was activated (\code{\var{activate} == 1}) or deactivated |
| 222 | (\code{\var{activate} == 0}). Handle things like focus highlighting, |
| 223 | etc. |
| 224 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 225 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 226 | |
| 227 | \subsection{ControlsWindow Object \label{controlswindow-object}} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 228 | |
| 229 | ControlsWindow objects have the following methods besides those of |
| 230 | \code{Window} objects: |
| 231 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 232 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 233 | \begin{methoddesc}[ControlsWindow]{do_controlhit}{window, control, |
| 234 | pcode, event} |
| 235 | Part \var{pcode} of control \var{control} was hit by the |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 236 | user. Tracking and such has already been taken care of. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 237 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 238 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 239 | |
| 240 | \subsection{ScrolledWindow Object \label{scrolledwindow-object}} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 241 | |
| 242 | ScrolledWindow objects are ControlsWindow objects with the following |
| 243 | extra methods: |
| 244 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 245 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 246 | \begin{methoddesc}[ScrolledWindow]{scrollbars}{\optional{wantx\optional{, |
| 247 | wanty}}} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 248 | Create (or destroy) horizontal and vertical scrollbars. The arguments |
| 249 | specify which you want (default: both). The scrollbars always have |
| 250 | minimum \code{0} and maximum \code{32767}. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 251 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 252 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 253 | \begin{methoddesc}[ScrolledWindow]{getscrollbarvalues}{} |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 254 | You must supply this method. It should return a tuple \code{(\var{x}, |
| 255 | \var{y})} giving the current position of the scrollbars (between |
| 256 | \code{0} and \code{32767}). You can return \code{None} for either to |
| 257 | indicate the whole document is visible in that direction. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 258 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 259 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 260 | \begin{methoddesc}[ScrolledWindow]{updatescrollbars}{} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 261 | Call this method when the document has changed. It will call |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 262 | \method{getscrollbarvalues()} and update the scrollbars. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 263 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 264 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 265 | \begin{methoddesc}[ScrolledWindow]{scrollbar_callback}{which, what, value} |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 266 | Supplied by you and called after user interaction. \var{which} will |
| 267 | be \code{'x'} or \code{'y'}, \var{what} will be \code{'-'}, |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 268 | \code{'--'}, \code{'set'}, \code{'++'} or \code{'+'}. For |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 269 | \code{'set'}, \var{value} will contain the new scrollbar position. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 270 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 271 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 272 | \begin{methoddesc}[ScrolledWindow]{scalebarvalues}{absmin, absmax, |
| 273 | curmin, curmax} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 274 | Auxiliary method to help you calculate values to return from |
Fred Drake | 41788db | 1998-04-04 06:23:02 +0000 | [diff] [blame] | 275 | \method{getscrollbarvalues()}. You pass document minimum and maximum value |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 276 | and topmost (leftmost) and bottommost (rightmost) visible values and |
| 277 | it returns the correct number or \code{None}. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 278 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 279 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 280 | \begin{methoddesc}[ScrolledWindow]{do_activate}{onoff, event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 281 | Takes care of dimming/highlighting scrollbars when a window becomes |
Fred Drake | 658865c | 2000-10-14 04:53:31 +0000 | [diff] [blame] | 282 | frontmost. If you override this method, call this one at the end of |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 283 | your method. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 284 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 285 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 286 | \begin{methoddesc}[ScrolledWindow]{do_postresize}{width, height, window} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 287 | Moves scrollbars to the correct position. Call this method initially |
| 288 | if you override it. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 289 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 290 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 291 | \begin{methoddesc}[ScrolledWindow]{do_controlhit}{window, control, |
| 292 | pcode, event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 293 | Handles scrollbar interaction. If you override it call this method |
| 294 | first, a nonzero return value indicates the hit was in the scrollbars |
| 295 | and has been handled. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 296 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 297 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 298 | |
| 299 | \subsection{DialogWindow Objects \label{dialogwindow-objects}} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 300 | |
| 301 | DialogWindow objects have the following methods besides those of |
| 302 | \code{Window} objects: |
| 303 | |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 304 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 305 | \begin{methoddesc}[DialogWindow]{open}{resid} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 306 | Create the dialog window, from the DLOG resource with id |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 307 | \var{resid}. The dialog object is stored in \member{self.wid}. |
| 308 | \end{methoddesc} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 309 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 310 | \begin{methoddesc}[DialogWindow]{do_itemhit}{item, event} |
Fred Drake | b4efb6c | 1998-02-18 17:19:11 +0000 | [diff] [blame] | 311 | Item number \var{item} was hit. You are responsible for redrawing |
| 312 | toggle buttons, etc. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 313 | \end{methoddesc} |