forked from slyrus/mcclim-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protocol-classes.lisp
226 lines (172 loc) · 6.61 KB
/
protocol-classes.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
;;; -*- Mode: Lisp; Package: CLIM-INTERNALS -*-
;;; (c) copyright 2006 by Tim Moore ([email protected])
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Library General Public
;;; License as published by the Free Software Foundation; either
;;; version 2 of the License, or (at your option) any later version.
;;;
;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;; Library General Public License for more details.
;;;
;;; You should have received a copy of the GNU Library General Public
;;; License along with this library; if not, write to the
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;;; Boston, MA 02111-1307 USA.
;;; Collect all the class definitions in the Spec in one file that is compiled
;;; and loaded early.
(in-package :clim-internals)
(defmacro define-protocol-class (name super-classes &optional slots &rest options)
(let* ((sym-name (symbol-name name))
(protocol-predicate
(intern (concatenate 'string
sym-name
(if (find #\- sym-name) "-" "")
(symbol-name '#:p))))
(predicate-docstring
(concatenate 'string
"Protocol predicate checking for class " sym-name)))
`(progn
(defclass ,name ,super-classes ,slots ,@options)
(let ((the-class (find-class ',name)))
(setf (documentation the-class 'type) "CLIM protocol class")
(defmethod initialize-instance :after ((object ,name) &key &allow-other-keys)
(when (eq (class-of object) the-class)
(error "~S is a protocol class and thus can't be instantiated" ',name))))
(defgeneric ,protocol-predicate (object)
(:method ((object t))
nil)
(:method ((object ,name))
t)
(:documentation ,predicate-docstring))
',name)))
;;; 3.1 General Regions
(define-protocol-class bounding-rectangle ())
(define-protocol-class region (design))
(define-protocol-class path (region bounding-rectangle))
(define-protocol-class area (region bounding-rectangle))
(define-protocol-class region-set (region bounding-rectangle))
(define-protocol-class point (region bounding-rectangle))
(define-protocol-class polyline (path))
(define-protocol-class polygon (area))
(define-protocol-class line (polyline))
(define-protocol-class rectangle (polygon))
(define-protocol-class ellipse (area))
(define-protocol-class elliptical-arc (path))
;;; 5.1 Transformations
(define-protocol-class transformation ())
;;; 7.1 Basic Sheet Classes
(define-protocol-class sheet (bounding-rectangle))
;;; 8.2 Standard Device Events
(define-protocol-class event ()
())
;;; 8.3.1 Output Properties
(define-protocol-class medium ()
())
;;; 9.2 Ports
(define-protocol-class port ())
;;; 10.3 Line Styles
(define-protocol-class line-style ())
;;; 11.1 Text Styles
(define-protocol-class text-style ()
())
;;; 13.2 Basic Designs
(define-protocol-class design ())
;;; 13.3 Color class
(define-protocol-class color (design))
;;; 13.4
(define-protocol-class opacity (design))
;;; 15.2 Extended Output Streams
(define-protocol-class extended-output-stream
(fundamental-character-output-stream)
;; CLIM Specification says that E-O-S is a subclass of
;; OUTPUT-STREAM, but it does not says what is it.
())
;;; 15.3 The Text Cursor
(define-protocol-class cursor ())
;;; 16.2 Output Records
(define-protocol-class output-record (bounding-rectangle)
())
(define-protocol-class displayed-output-record (output-record)
())
;;; 16.3.2 Graphics Displayed Output Records
(define-protocol-class graphics-displayed-output-record
(displayed-output-record)
())
;;; 16.3.3 Text Displayed Output Record
(define-protocol-class text-displayed-output-record (displayed-output-record)
())
;;; 16.4 Output Recording Streams
(define-protocol-class output-recording-stream ()
())
;;; 17.3.1 Table Formatting Protocol
(define-protocol-class table-output-record (output-record))
;;; 17.3.2 Row and Column Formatting Protocol
(define-protocol-class row-output-record (output-record))
(define-protocol-class column-output-record (output-record))
;;; 17.3.3 Cell Formatting Protocol
(define-protocol-class cell-output-record (output-record))
;;; 17.3.4 Item List Formatting Protocol
(define-protocol-class item-list-output-record ()
())
;;; 18.2 The Graph Formatting Protocol
(define-protocol-class graph-output-record (output-record))
(define-protocol-class graph-node-output-record (output-record))
;;; 21.3 Incremental Redisplay Protocol
(define-protocol-class updating-output-record (output-record))
;;; 22.2 Extended Input Streams
(define-protocol-class extended-input-stream
(fundamental-character-input-stream)
())
;;; 22.4 The Pointer Protocol
(define-protocol-class pointer ()
())
;;; 23.2 Presentations
(define-protocol-class presentation ())
;;; 23.6 Views
(define-protocol-class view ())
;;; 24.1.1 The Input Editing Stream Protocol
(define-protocol-class input-editing-stream ())
;;; 27.2 Command Tables
(define-protocol-class command-table ()
())
;;; 28.2 Application Frames
(define-protocol-class application-frame ()
())
;;; 28.5 Frame Managers
;;; XXX The slot definitions shouldn't be here, but there is no
;;; standard-frame-manager and I don't want to add these slots to all the frame
;;; manager classes right now.
(define-protocol-class frame-manager ()
((port :initarg :port :reader port)
(frames :initform nil :reader frame-manager-frames)))
;;; 30.3 Basic Gadget Classes
;;; XXX Slots definitions should be banished.
(define-protocol-class gadget (pane)
((id :initarg :id
:initform (gensym "GADGET")
:accessor gadget-id)
(client :initarg :client
:initform *application-frame*
:accessor gadget-client)
(armed-callback :initarg :armed-callback
:initform nil
:reader gadget-armed-callback)
(disarmed-callback :initarg :disarmed-callback
:initform nil
:reader gadget-disarmed-callback)
;; [Arthur] I'm not so sure about the value for :initform.
;; Maybe T is better? Or maybe we should call
;; ACTIVATE-GADGET after creating a gadget?
;;
;; I think, T is correct here --GB
(active-p :initform t :initarg :active
:reader gadget-active-p)
;;
;; I am not so lucky with the armed slot in GADGET --GB
(armed :initform nil)
))
;;; C.1 Encapsulating Streams
(define-protocol-class encapsulating-stream ()
())