/[mcclim]/mcclim/dialog-views.lisp
ViewVC logotype

Contents of /mcclim/dialog-views.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Thu Dec 1 11:10:54 2005 UTC (8 years, 4 months ago) by gbaumann
Branch: MAIN
CVS Tags: mcclim-0-9-4, McCLIM-0-9-5, McCLIM-0-9-4, McCLIM-0-9-6, McCLIM-0-9-3, McCLIM-0-9-2, HEAD
Changes since 1.1: +1 -1 lines
- added more DEFGENERICs
- fiddled with a few IGNORE declarations
- with CMUCL, macros no longer attempt to declare special variables
  IGNORABLE
1 tmoore 1.1 ;;; -*- Mode: Lisp; Package: CLIM-INTERNALS -*-
2    
3     ;;; (c) copyright 2005 by Tim Moore (moore@bricoworks.com)
4     ;;; This library is free software; you can redistribute it and/or
5     ;;; modify it under the terms of the GNU Library General Public
6     ;;; License as published by the Free Software Foundation; either
7     ;;; version 2 of the License, or (at your option) any later version.
8     ;;;
9     ;;; This library is distributed in the hope that it will be useful,
10     ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11     ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     ;;; Library General Public License for more details.
13     ;;;
14     ;;; You should have received a copy of the GNU Library General Public
15     ;;; License along with this library; if not, write to the
16     ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17     ;;; Boston, MA 02111-1307 USA.
18    
19     (in-package :clim-internals)
20    
21     ;;; Classes for the gadget dialog views. Eventually.
22    
23     ;;; A gadget that's not in the spec but which would be useful.
24     (defclass pop-up-menu-view (gadget-dialog-view)
25     ()
26     (:documentation "A dialog view that presents the elements of a
27     COMPLETION presentation type as a pop-up menu."))
28    
29     (defparameter +pop-up-menu-view+ (make-instance 'pop-up-menu-view))
30    
31     ;;; By storing these parameters and options from the COMPLETION
32     ;;; presentation type in this object, we avoid having to dig them
33     ;;; out of the presentation type on each call to select-query. That
34     ;;; would not be possible if we are accepting a subtype of COMPLETION.
35     (defclass av-pop-up-menu-record (standard-updating-output-record)
36     ((pop-up-sequence :accessor pop-up-sequence :initform nil)
37     (pop-up-test :accessor pop-up-test :initform nil)
38     (pop-up-value-key :accessor pop-up-value-key :initform nil)
39     (pop-up-name-key :accessor pop-up-name-key :initform nil)))
40    
41     (define-presentation-method accept-present-default
42     ((type completion) stream (view pop-up-menu-view)
43     default default-supplied-p present-p query-identifier)
44     (declare (ignore present-p))
45     (unless default-supplied-p
46     (setq default (funcall value-key (elt sequence 0))))
47     (let ((record (updating-output (stream :unique-id query-identifier
48     :cache-value default
49     :record-type 'av-pop-up-menu-record)
50     (with-output-as-presentation
51     (stream query-identifier 'selectable-query)
52     (surrounding-output-with-border
53     (stream :shape :inset :move-cursor t)
54     (write-string (funcall name-key default) stream))))))
55     (setf (pop-up-sequence record) sequence)
56     (setf (pop-up-test record) test)
57     (setf (pop-up-value-key record) value-key)
58     (setf (pop-up-name-key record) name-key)
59     record))
60    
61     (defmethod select-query (stream query (record av-pop-up-menu-record))
62     (declare (ignore stream))
63     (let* ((value-key (pop-up-value-key record))
64     (name-key (pop-up-name-key record)))
65     (multiple-value-bind (new-value item event)
66     (menu-choose (map 'list
67     #'(lambda (item)
68     `(,(funcall name-key item)
69     :value ,(funcall value-key item)))
70     (pop-up-sequence record)))
71     (declare (ignore item))
72     (when event
73     (setf (value query) new-value)
74     (setf (changedp query) t)))))
75    
76     (defmethod deselect-query (stream query (record av-pop-up-menu-record))
77     (declare (ignore stream query))
78     nil)
79    
80     (defmethod finalize-query-record (query (record av-pop-up-menu-record))
81 gbaumann 1.2 (declare (ignore query))
82 tmoore 1.1 nil)
83    

  ViewVC Help
Powered by ViewVC 1.1.5