/[mcclim]/mcclim/frames.lisp
ViewVC logotype

Contents of /mcclim/frames.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.42 - (show annotations)
Tue Jul 9 17:18:06 2002 UTC (11 years, 9 months ago) by adejneka
Branch: MAIN
Changes since 1.41: +1 -1 lines
DEFAULT-FRAME-TOPLEVEIL: Clear panes with their history.
1 ;;; -*- Mode: Lisp; Package: CLIM-INTERNALS -*-
2
3 ;;; (c) copyright 1998,1999,2000 by Michael McDonald (mikemac@mikemac.com)
4 ;;; (c) copyright 2000 by
5 ;;; Iban Hatchondo (hatchond@emi.u-bordeaux.fr)
6 ;;; Julien Boninfante (boninfan@emi.u-bordeaux.fr)
7 ;;; Robert Strandh (strandh@labri.u-bordeaux.fr)
8
9 ;;; This library is free software; you can redistribute it and/or
10 ;;; modify it under the terms of the GNU Library General Public
11 ;;; License as published by the Free Software Foundation; either
12 ;;; version 2 of the License, or (at your option) any later version.
13 ;;;
14 ;;; This library is distributed in the hope that it will be useful,
15 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;;; Library General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU Library General Public
20 ;;; License along with this library; if not, write to the
21 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;;; Boston, MA 02111-1307 USA.
23
24 (in-package :CLIM-INTERNALS)
25
26 ;; *application-frame* is in decls.lisp
27 (defvar *default-frame-manager* nil)
28
29 ;;; Frame-Manager class
30
31 (defclass frame-manager ()
32 ((port :initarg :port
33 :reader frame-manager-port)
34 (frames :initform nil
35 :reader frame-manager-frames)
36 )
37 )
38
39 (defun frame-manager-p (x)
40 (typep x 'frame-manager))
41
42 (defun find-frame-manager (&rest options &key port &allow-other-keys)
43 (declare (special *frame-manager*))
44 (if (boundp '*frame-manager*)
45 *frame-manager*
46 (if (and *default-frame-manager*
47 (frame-manager-p *default-frame-manager*))
48 *default-frame-manager*
49 (first (frame-managers (or port (apply #'find-port options)))))))
50
51 (defmacro with-frame-manager ((frame-manager) &body body)
52 `(let (('*frame-manager* ,frame-manager))
53 (declare (special *frame-manager*))
54 (block ,@body)))
55
56 ;;; Application-Frame class
57 ;;; XXX All these slots should move to a mixin or to standard-application-frame.
58 ;;; -- moore
59
60 (defclass application-frame ()
61 ((port :initform nil
62 :initarg :port
63 :accessor port)
64 (graft :initform nil
65 :initarg :graft
66 :accessor graft)
67 (name :initarg :name
68 :reader frame-name)
69 (pretty-name :initarg :pretty-name
70 :accessor frame-pretty-name)
71 (command-table :initarg :command-table
72 :initform nil
73 :accessor frame-command-table)
74 (disabled-commands :initarg :disabled-commands
75 :initform nil
76 :accessor frame-disabled-commands)
77 (pane :reader frame-pane)
78 (panes :initform nil
79 :reader frame-panes)
80 (layouts :initform nil
81 :initarg :layouts
82 :reader frame-layouts)
83 (current-layout :initform nil
84 :initarg :current-layout
85 :reader frame-current-layout)
86 (top-level-sheet :initform nil
87 :reader frame-top-level-sheet)
88 (menu-bar :initarg :menu-bar
89 :initform nil)
90 (calling-frame :initarg :calling-frame
91 :initform nil)
92 (state :initarg :state
93 :initform nil
94 :accessor frame-state)
95 (manager :initform nil
96 :reader frame-manager)
97 (properties :initarg :properties
98 :initform nil)
99 (top-level :initform '(default-frame-top-level)
100 :initarg :top-level
101 :reader frame-top-level)
102 (hilited-presentation :initform nil
103 :initarg :hilited-presentation
104 :accessor frame-hilited-presentation)))
105
106 (defun application-frame-p (x)
107 (typep x 'application-frame))
108
109 (defmethod initialize-instance :after ((frame application-frame) &rest args)
110 (declare (ignore args)))
111
112 ;;; Generic operations
113 ; (defgeneric frame-name (frame))
114 ; (defgeneric frame-pretty-name (frame))
115 ; (defgeneric (setf frame-pretty-name) (name frame))
116 ; (defgeneric frame-command-table (frame))
117 ; (defgeneric (setf frame-command-table) (command-table frame))
118 (defgeneric frame-standard-output (frame)
119 (:documentation
120 "Returns the stream that will be used for *standard-output* for the FRAME."))
121 (defgeneric frame-standard-input (frame)
122 (:documentation
123 "Returns the stream that will be used for *standard-input* for the FRAME."))
124 (defgeneric frame-query-io (frame)
125 (:documentation
126 "Returns the stream that will be used for *query-io* for the FRAME."))
127 (defgeneric frame-error-output (frame)
128 (:documentation
129 "Returns the stream that will be used for *error-output* for the FRAME."))
130 (defgeneric frame-pointer-documentation-output (frame)
131 (:documentation
132 "Returns the stream that will be used for *pointer-documentation-output*
133 for the FRAME."))
134 (defgeneric frame-calling-frame (frame)
135 (:documentation
136 "Returns the application frame that invoked the FRAME."))
137 (defgeneric frame-parent (frame)
138 (:documentation
139 "Returns the object that acts as the parent for the FRAME."))
140 ;(defgeneric frame-pane (frame) ; XXX Is it in Spec?
141 ; (:documentation
142 ; "Returns the pane that is the top-level pane in the current layout
143 ;of the FRAME's named panes."))
144 (defgeneric frame-top-level-sheet (frame)
145 (:documentation
146 "Returns the shhet that is the top-level sheet for the FRAME. This
147 is the sheet that has as its descendants all of the panes of the FRAME."))
148 (defgeneric frame-current-panes (frame)
149 (:documentation
150 "Returns a list of those named panes in the FRAME's current layout.
151 If there are no named panes, only the single, top level pane is returned."))
152 (defgeneric get-frame-pane (frame pane-name)
153 (:documentation
154 "Returns the named CLIM stream pane in the FRAME whose name is PANE-NAME."))
155 (defgeneric find-pane-named (frame pane-name)
156 (:documentation
157 "Returns the pane in the FRAME whose name is PANE-NAME."))
158 ;(defgeneric frame-current-layout (frame))
159 ;(defgeneric frame-all-layouts (frame)) ; XXX Is it in Spec?
160 (defgeneric layout-frame (frame &optional width height))
161 (defgeneric frame-exit-frame (condition)
162 (:documentation
163 "Returns the frame that is being exited from associated with the
164 FRAME-EXIT condition."))
165 (defgeneric frame-exit (frame) ; XXX Is it in Spec?
166 (:documentation
167 "Exits from the FRAME."))
168 (defgeneric pane-needs-redisplay (pane))
169 (defgeneric (setf pane-needs-redisplay) (value pane))
170 (defgeneric redisplay-frame-pane (frame pane &key force-p))
171 (defgeneric redisplay-frame-panes (frame &key force-p))
172 (defgeneric frame-replay (frame stream &optional region))
173 (defgeneric notify-user (frame message &key associated-window title
174 documentation exit-boxes name style text-style))
175 ;(defgeneric frame-properties (frame property))
176 ;(defgeneric (setf frame-properties) (value frame property))
177
178
179 (defclass standard-application-frame (application-frame)
180 ((event-queue :initarg :frame-event-queue
181 :accessor frame-event-queue
182 :documentation "The event queue that, by default, will be
183 shared by all panes in the stream")))
184
185 ;;; Support the :input-buffer initarg for compatibility with "real CLIM"
186
187 (defmethod initialize-instance :after ((obj standard-application-frame)
188 &key (input-buffer nil input-buffer-p))
189 (cond (input-buffer-p
190 (setf (frame-event-queue obj) input-buffer))
191 ((not (slot-boundp obj 'event-queue))
192 (setf (frame-event-queue obj) (make-instance 'standard-event-queue)))
193 (t nil)))
194
195
196 (defmethod (setf frame-manager) (fm (frame application-frame))
197 (let ((old-manager (frame-manager frame)))
198 (setf (slot-value frame 'manager) nil)
199 (when old-manager
200 (disown-frame old-manager frame)
201 (setf (slot-value frame 'panes) nil)
202 (setf (slot-value frame 'layouts) nil))
203 (setf (slot-value frame 'manager) fm)))
204
205 (defmethod (setf frame-current-layout) (name (frame application-frame))
206 (declare (ignore name))
207 (generate-panes (frame-manager frame) frame))
208
209 (defmethod generate-panes :before (fm (frame application-frame))
210 (declare (ignore fm))
211 (when (and (slot-boundp frame 'pane)
212 (frame-pane frame))
213 (sheet-disown-child (frame-top-level-sheet frame) (frame-pane frame))))
214
215 (defmethod generate-panes :after (fm (frame application-frame))
216 (declare (ignore fm))
217 (sheet-adopt-child (frame-top-level-sheet frame) (frame-pane frame))
218 (sheet-adopt-child (graft frame) (frame-top-level-sheet frame))
219 (let ((space (compose-space (frame-top-level-sheet frame))))
220 ;; automatically generates a window-configuation-event
221 ;; which then calls allocate-space
222 ;;
223 ;; Not any longer, we turn of CONFIGURE-NOTIFY events until the
224 ;; window is mapped and do the space allocation now, so that all
225 ;; sheets will have their correct geometry at once. --GB
226 (setf (sheet-region (frame-top-level-sheet frame))
227 (make-bounding-rectangle 0 0
228 (space-requirement-width space)
229 (space-requirement-height space)))
230 (allocate-space (frame-top-level-sheet frame)
231 (space-requirement-width space)
232 (space-requirement-height space)) ))
233
234 (defmethod layout-frame ((frame application-frame) &optional width height)
235 (let ((pane (frame-pane frame)))
236 (if (and width (not height))
237 (error "LAYOUT-FRAME must be called with both WIDTH and HEIGHT or neither"))
238 (if (and (null width) (null height))
239 (let ((space (compose-space pane)))
240 (setq width (space-requirement-width space))
241 (setq height (space-requirement-height space))))
242 (allocate-space pane width height)))
243
244 (defun find-pane-if (predicate panes)
245 "Returns a pane satisfying PREDICATE in the forest growing from PANES"
246 (loop for pane in panes
247 do (map-over-sheets #'(lambda (p)
248 (when (funcall predicate p)
249 (return-from find-pane-if p)))
250 pane)
251 finally (return nil)))
252
253 (defun find-pane-of-type (panes type)
254 (find-pane-if #'(lambda (pane) (typep pane type)) panes))
255
256 (defmethod frame-current-panes ((frame application-frame))
257 (find-pane-if #'(lambda (pane) (pane-name pane))
258 (frame-current-layout frame)))
259
260 (defmethod get-frame-pane ((frame application-frame) pane-name)
261 (find-pane-if #'(lambda (pane)
262 (and (typep pane 'clim-stream-pane)
263 (eq pane-name
264 (pane-name pane))))
265 (frame-panes frame)))
266
267 (defmethod find-pane-named ((frame application-frame) pane-name)
268 (find-pane-if #'(lambda (pane)
269 (eq pane-name
270 (pane-name pane)))
271 (frame-panes frame)))
272
273 (defmethod frame-standard-output ((frame application-frame))
274 (or (find-pane-of-type (frame-panes frame) 'application-pane)
275 (find-pane-of-type (frame-panes frame) 'interactor-pane)))
276
277 (defmethod frame-standard-input ((frame application-frame))
278 (or (find-pane-of-type (frame-panes frame) 'interactor-pane)
279 (frame-standard-output frame)))
280
281 (defmethod frame-query-io ((frame application-frame))
282 (or (frame-standard-input frame)
283 (frame-standard-output frame)))
284
285 (defmethod frame-error-output ((frame application-frame))
286 (frame-standard-output frame))
287
288 (defvar *pointer-documentation-output* nil)
289
290 (defmethod frame-pointer-documentation-output ((frame application-frame))
291 (find-pane-of-type (frame-panes frame) 'pointer-documentation-pane))
292
293 ;;; Command loop interface
294
295 (define-condition frame-exit (condition)
296 ((frame :initarg :frame :reader %frame-exit-frame)))
297
298 (defmethod frame-exit ((frame standard-application-frame))
299 (signal 'frame-exit :frame frame))
300
301 (defmethod frame-exit-frame ((c frame-exit))
302 (%frame-exit-frame c))
303
304 (defmethod run-frame-top-level ((frame application-frame))
305 (handler-bind ((frame-exit #'(lambda (condition)
306 (declare (ignore condition))
307 (return-from run-frame-top-level nil))))
308 (apply (first (frame-top-level frame)) frame (rest (frame-top-level frame)))))
309
310 (defmethod run-frame-top-level :around ((frame application-frame))
311 (let ((*application-frame* frame)
312 (*input-context* nil)
313 (*input-wait-test* nil)
314 (*input-wait-handler* nil)
315 (*pointer-button-press-handler* nil))
316 (declare (special *input-context* *input-wait-test* *input-wait-handler*
317 *pointer-button-press-handler*))
318 (let ((query-io (frame-query-io frame)))
319 (if query-io
320 (with-input-focus (query-io)
321 (call-next-method))
322 (call-next-method)))))
323
324 (defmethod default-frame-top-level
325 ((frame application-frame)
326 &key (command-parser 'command-line-command-parser)
327 (command-unparser 'command-line-command-unparser)
328 (partial-command-parser
329 'command-line-read-remaining-arguments-for-partial-command)
330 (prompt "Command: "))
331 (loop
332 (let ((*standard-input* (frame-standard-input frame))
333 (*standard-output* (frame-standard-output frame))
334 (*query-io* (frame-query-io frame))
335 ;; during development, don't alter *error-output*
336 ;; (*error-output* (frame-error-output frame))
337 (*command-parser* command-parser)
338 (*command-unparser* command-unparser)
339 (*partial-command-parser* partial-command-parser)
340 (prompt-style (make-text-style :fix :italic :normal)))
341 (map-over-sheets #'(lambda (pane)
342 (if (and (typep pane 'clim-stream-pane)
343 (eq (pane-display-time pane) :command-loop)
344 (pane-display-function pane))
345 (let ((func (pane-display-function pane)))
346 (window-clear pane)
347 (funcall func frame pane) ; XXX other arguments
348 ; XXX incremental redisplay
349 )))
350 (frame-top-level-sheet frame))
351 (when *standard-input*
352 (setf (cursor-visibility (stream-text-cursor *standard-input*)) t)
353 (when prompt
354 (with-text-style (*standard-input* prompt-style)
355 (if (stringp prompt)
356 (write-string prompt *standard-input*)
357 (funcall prompt *standard-input* frame))
358 (finish-output *standard-input*)))
359 (let ((command (read-frame-command frame)))
360 (fresh-line *standard-input*)
361 (when command
362 (execute-frame-command frame command))
363 (fresh-line *standard-input*))))))
364
365
366 (defmethod read-frame-command ((frame application-frame) &key (stream *standard-input*))
367 (read-command (frame-command-table frame) :stream stream))
368
369 (defmethod execute-frame-command ((frame application-frame) command)
370 (apply (command-name command) (command-arguments command)))
371
372 (defmethod make-pane-1 ((fm frame-manager) (frame application-frame) type &rest args)
373 `(make-pane-1 ,fm ,frame ',type ,@args))
374
375 (defmethod make-pane-1 :around (fm (frame standard-application-frame) type
376 &rest args
377 &key (input-buffer nil input-buffer-p))
378 "Default input-buffer to the frame event queue."
379 (if input-buffer-p
380 (call-next-method)
381 (apply #'call-next-method fm frame type
382 :input-buffer (frame-event-queue frame)
383 args)))
384
385 (defmethod adopt-frame ((fm frame-manager) (frame application-frame))
386 (setf (slot-value fm 'frames) (cons frame (slot-value fm 'frames)))
387 (setf (frame-manager frame) fm)
388 (let* ((*application-frame* frame)
389 (t-l-s (make-pane-1 fm frame 'top-level-sheet-pane
390 :name 'top-level-sheet)))
391 (setf (slot-value frame 'top-level-sheet) t-l-s)
392 (generate-panes fm frame)))
393
394 (defmethod disown-frame ((fm frame-manager) (frame application-frame))
395 (setf (slot-value fm 'frames) (remove frame (slot-value fm 'frames)))
396 (sheet-disown-child (graft frame) (frame-top-level-sheet frame))
397 (setf (frame-manager frame) nil))
398
399 (defvar *pane-realizer* nil)
400
401 (defmacro with-look-and-feel-realization ((frame-manager frame) &body body)
402 `(let ((*pane-realizer* ,frame-manager)
403 (*application-frame* ,frame))
404 (progn
405 ,@body)))
406
407 ; The menu-bar code in the following two functions is incorrect.
408 ; it needs to be moved to somewhere after the backend, since
409 ; it depends on the backend chosen.
410 ;
411 ; This hack slaps a menu-bar into the start of the application-frame,
412 ; in such a way that it is hard to find.
413 ;
414 ; FIXME
415 (defun make-single-pane-generate-panes-form (class-name menu-bar pane)
416 `(defmethod generate-panes ((fm frame-manager) (frame ,class-name))
417 ; v-- hey, how can this be?
418 (with-look-and-feel-realization (fm frame)
419 (let ((pane ,(cond
420 ((eq menu-bar t)
421 `(vertically () (clim-internals::make-menu-bar
422 ',class-name)
423 ,pane))
424 ((consp menu-bar)
425 `(vertically () (clim-internals::make-menu-bar
426 (make-command-table nil
427 :menu ',menu-bar))
428 ,pane))
429 (menu-bar
430 `(vertically () (clim-internals::make-menu-bar
431 ',menu-bar)
432 ,pane))
433 ;; The form below is unreachable with (listp
434 ;; menu-bar) instead of (consp menu-bar) above
435 ;; --GB
436 (t pane))))
437 (setf (slot-value frame 'pane) pane)))))
438
439 ; could do with some refactoring [BTS] FIXME
440 (defun make-panes-generate-panes-form (class-name menu-bar panes layouts)
441 `(defmethod generate-panes ((fm frame-manager) (frame ,class-name))
442 (let ((*application-frame* frame))
443 (with-look-and-feel-realization (fm frame)
444 (let ,(loop for (name . form) in panes
445 collect `(,name (or (find-pane-named frame ',name)
446 (let ((pane
447 ,(cond
448 ((and (= (length form) 1)
449 (listp (first form)))
450 (first form))
451 ((keywordp (first form))
452 (let ((maker (intern (concatenate 'string
453 "MAKE-CLIM-"
454 (symbol-name (first form))
455 "-PANE") :clim)))
456 (if (fboundp maker)
457 `(,maker :name ',name ,@(cdr form))
458 `(make-pane ',(first form)
459 :name ',name ,@(cdr form)))))
460 (t `(make-pane ',(first form) :name ',name ,@(cdr form))))))
461 ;; hmm?! --GB
462 (setf (slot-value pane 'name) ',name)
463 ;;
464 (push pane (slot-value frame 'panes))
465 pane))))
466 ; [BTS] added this, but is not sure that this is correct for adding
467 ; a menu-bar transparently, should also only be done where the
468 ; exterior window system does not support menus
469 ,(if menu-bar
470 `(setf (slot-value frame 'pane)
471 (ecase (frame-current-layout frame)
472 ,@(mapcar (lambda (layout)
473 `(,(first layout) (vertically ()
474 ,(cond
475 ((eq menu-bar t)
476 `(clim-internals::make-menu-bar
477 ',class-name))
478 ((consp menu-bar)
479 `(raising (:border-width 2 :background +Gray83+)
480 (clim-internals::make-menu-bar
481 (make-command-table nil
482 :menu ',menu-bar))))
483 (menu-bar
484 `(clim-internals::make-menu-bar
485 ',menu-bar)))
486 ,@(rest layout))))
487 layouts)))
488 `(setf (slot-value frame 'pane)
489 (ecase (frame-current-layout frame)
490 ,@layouts))))))))
491
492 (defmacro define-application-frame (name superclasses slots &rest options)
493 (if (null superclasses)
494 (setq superclasses '(standard-application-frame)))
495 (let ((pane nil)
496 (panes nil)
497 (layouts nil)
498 (current-layout nil)
499 (command-table (list name))
500 (menu-bar t)
501 (disabled-commands nil)
502 (command-definer t)
503 (top-level '(default-frame-top-level))
504 (others nil)
505 (command-name (intern (concatenate 'string "DEFINE-" (symbol-name name) "-COMMAND"))))
506 (loop for (prop . values) in options
507 do (case prop
508 (:pane (setq pane (first values)))
509 (:panes (setq panes values))
510 (:layouts (setq layouts values))
511 (:command-table (setq command-table (first values)))
512 (:menu-bar (setq menu-bar (if (listp values)
513 (first values)
514 values)))
515 (:disabled-commands (setq disabled-commands values))
516 (:command-definer (setq command-definer (first values)))
517 (:top-level (setq top-level (first values)))
518 (t (push (cons prop values) others))))
519 (if (or (and pane panes)
520 (and pane layouts))
521 (error ":pane cannot be specified along with either :panes or :layouts"))
522 (if pane
523 (setq panes (list 'single-pane pane)
524 layouts `((:default ,(car pane)))))
525 (setq current-layout (first (first layouts)))
526 `(progn
527 (defclass ,name ,superclasses
528 ,slots
529 (:default-initargs
530 :name ',name
531 :pretty-name ,(string-capitalize name)
532 :command-table (find-command-table ',(first command-table))
533 :disabled-commands ',disabled-commands
534 :menu-bar ',menu-bar
535 :current-layout ',current-layout
536 :layouts ',layouts
537 :top-level ',top-level
538 )
539 ,@others)
540 ,(if pane
541 (make-single-pane-generate-panes-form name menu-bar pane)
542 (make-panes-generate-panes-form name menu-bar panes layouts))
543 ,@(if command-table
544 `((define-command-table ,@command-table)))
545 ,@(if command-definer
546 `((defmacro ,command-name (name-and-options arguements &rest body)
547 (let ((name (if (listp name-and-options) (first name-and-options) name-and-options))
548 (options (if (listp name-and-options) (cdr name-and-options) nil))
549 (command-table ',(first command-table)))
550 `(define-command (,name :command-table ,command-table ,@options) ,arguements ,@body))))))))
551
552 (defun make-application-frame (frame-name
553 &rest options
554 &key pretty-name frame-manager enable state
555 left top right bottom width height save-under
556 frame-class
557 &allow-other-keys)
558 (declare (ignore enable state left top right bottom width height save-under))
559 (setq options (loop for (key value) on options by #'cddr
560 if (not (member key '(:pretty-name :frame-manager :enable :state
561 :left :top :right :bottom :width :height :save-under
562 :frame-class)
563 :test #'eq))
564 nconc (list key value)))
565 (if (null frame-class)
566 (setq frame-class frame-name))
567 (if (null pretty-name)
568 (setq pretty-name (string-capitalize frame-name)))
569 (if (null frame-manager)
570 (setq frame-manager (find-frame-manager)))
571 (let ((frame (apply #'make-instance frame-class
572 :port (frame-manager-port frame-manager)
573 :graft (find-graft :port (frame-manager-port frame-manager))
574 :name frame-name :pretty-name pretty-name options)))
575 (adopt-frame frame-manager frame)
576 frame))
577
578 ;;; Menu frame class
579
580 (defclass menu-frame ()
581 ((left :initform 0 :initarg :left)
582 (top :initform 0 :initarg :top)
583 (top-level-sheet :initform nil :reader frame-top-level-sheet)
584 (pane :reader frame-pane :initarg :pane)
585 (graft :initform nil :accessor graft)
586 (manager :initform nil :accessor frame-manager)))
587
588 (defmethod adopt-frame ((fm frame-manager) (frame menu-frame))
589 (setf (slot-value fm 'frames) (cons frame (slot-value fm 'frames)))
590 (setf (slot-value frame 'manager) fm)
591 (let* ((t-l-s (make-pane-1 fm *application-frame* 'unmanaged-top-level-sheet-pane
592 :name 'top-level-sheet)))
593 (setf (slot-value frame 'top-level-sheet) t-l-s)
594 (sheet-adopt-child t-l-s (frame-pane frame))
595 (let ((graft (find-graft :port (frame-manager-port fm))))
596 (sheet-adopt-child graft t-l-s)
597 (setf (graft frame) graft))
598 (let ((space (compose-space t-l-s)))
599 (allocate-space (frame-pane frame)
600 (space-requirement-width space)
601 (space-requirement-height space))
602 (setf (sheet-region t-l-s)
603 (make-bounding-rectangle 0 0
604 (space-requirement-width space)
605 (space-requirement-height space))))
606 (setf (sheet-transformation t-l-s)
607 (make-translation-transformation (slot-value frame 'left)
608 (slot-value frame 'top)))))
609
610 (defmethod disown-frame ((fm frame-manager) (frame menu-frame))
611 (setf (slot-value fm 'frames) (remove frame (slot-value fm 'frames)))
612 (sheet-disown-child (graft frame) (frame-top-level-sheet frame))
613 (setf (frame-manager frame) nil))
614
615 (defun make-menu-frame (pane &key (left 0) (top 0))
616 (make-instance 'menu-frame :pane pane :left left :top top))
617
618 ;;; Frames and presentations
619
620 (defmethod frame-find-innermost-applicable-presentation
621 ((frame standard-application-frame) input-context stream x y
622 &key event)
623 (find-innermost-applicable-presentation input-context stream
624 x y
625 :frame frame :event event))
626
627 (defmethod frame-input-context-button-press-handler
628 ((frame standard-application-frame)
629 (stream output-recording-stream)
630 button-press-event)
631 (format *debug-io* "frame button press event: ~D ~D in ~S~%"
632 (pointer-event-x button-press-event)
633 (pointer-event-y button-press-event)
634 stream)
635 (let ((presentation (find-innermost-applicable-presentation
636 *input-context*
637 stream
638 (pointer-event-x button-press-event)
639 (pointer-event-y button-press-event)
640 :frame frame
641 :event button-press-event)))
642 (when presentation
643 (format *debug-io* "presentation: ~S of type ~S~%"
644 (presentation-object presentation)
645 (presentation-type presentation))
646 (throw-highlighted-presentation presentation
647 *input-context*
648 button-press-event))))
649
650 (defmethod frame-input-context-button-press-handler
651 ((frame standard-application-frame) stream button-press-event)
652 (declare (ignore stream button-press-event))
653 nil)
654
655 (defmethod frame-input-context-track-pointer
656 ((frame standard-application-frame)
657 input-context
658 (stream output-recording-stream) event)
659 (declare (ignore input-context event))
660 nil)
661
662 (defmethod frame-input-context-track-pointer
663 ((frame standard-application-frame) input-context stream event)
664 (declare (ignore input-context stream event))
665 nil)
666
667 (defmethod frame-input-context-track-pointer :before
668 ((frame standard-application-frame) input-context stream event)
669 (if (output-recording-stream-p stream)
670 (let ((presentation (find-innermost-applicable-presentation
671 input-context
672 stream
673 (pointer-event-x event)
674 (pointer-event-y event)
675 :frame frame
676 :modifier-state (event-modifier-state event))))
677 (when (and (frame-hilited-presentation frame)
678 (not (eq presentation
679 (car (frame-hilited-presentation frame)))))
680 (highlight-presentation-1 (car (frame-hilited-presentation frame))
681 (cdr (frame-hilited-presentation frame))
682 :unhighlight))
683 (if presentation
684 (when (not (eq presentation
685 (car (frame-hilited-presentation frame))))
686 (setf (frame-hilited-presentation frame)
687 (cons presentation stream))
688 (highlight-presentation-1 presentation stream :highlight))
689 (setf (frame-hilited-presentation frame) nil)))))
690
691
692 (defun simple-event-loop ()
693 "An simple event loop for applications that want all events to be handled by
694 handle-event methods"
695 (let ((queue (frame-event-queue *application-frame*)))
696 (loop for event = (event-queue-read queue)
697 ;; EVENT-QUEUE-READ in single-process mode calls PROCESS-NEXT-EVENT itself.
698 do (handle-event (event-sheet event) event))))

  ViewVC Help
Powered by ViewVC 1.1.5