| 1 |
;;; |
| 2 |
;;; Xview Class package for euslisp |
| 3 |
;;; Using xview.c |
| 4 |
;;; xviewconst.l |
| 5 |
;;; 1989.11.10 version 1 |
| 6 |
;;; Masayuki Inaba |
| 7 |
;;; |
| 8 |
;;; The University of Tokyo |
| 9 |
;;; Faculty of Engineering |
| 10 |
;;; Department of Mechanical Engineering |
| 11 |
;;; Information System Engineering Laboratory |
| 12 |
;;; Tel. 03-812-2111 ext. 6345(office) |
| 13 |
;;; 7416(laboratory) |
| 14 |
;;; |
| 15 |
;;; |
| 16 |
(eval-when |
| 17 |
(compile) |
| 18 |
(load "/usr/local/eus/geo/geoclasses.l") |
| 19 |
(load "/usr/local/eus/xview/xviewclasses.l") |
| 20 |
(load "/usr/local/eus/xview/xviewconst.l") |
| 21 |
) |
| 22 |
|
| 23 |
(defvar xview-directory) |
| 24 |
|
| 25 |
|
| 26 |
(defvar *font-directories* '("/usr/share/lib/X11/fonts" |
| 27 |
"/usr/share/lib/X11/fonts/misc" |
| 28 |
"/usr/share/lib/X11/fonts/75dpi" |
| 29 |
"/usr/share/lib/X11/fonts/100dpi")) |
| 30 |
|
| 31 |
(defvar *icon-directories* '("/usr/share/include/X11/Xview/images")) |
| 32 |
|
| 33 |
(defun string-body-address (str) (+ 8 (system:address str))) |
| 34 |
|
| 35 |
(defun window-cadr-to-object (c) |
| 36 |
(cdr (assoc c xview-directory))) |
| 37 |
(defun item-cadr-to-object (cadr) |
| 38 |
(let* |
| 39 |
((panel-cadr (panel_get cadr panel_parent_panel)) |
| 40 |
(panel (window-cadr-to-object panel-cadr))) |
| 41 |
(if panel |
| 42 |
(cdr (assq cadr (panel . item-object-list)))))) |
| 43 |
|
| 44 |
(defun hardcopy (&optional (fname (format nil "temp.ps")) |
| 45 |
&key (scale 2) (direction t) |
| 46 |
(x 1) (y 1) (wx 1150) (wy 876) |
| 47 |
(offset #f(1.0 1.0))) ;;; inches |
| 48 |
(unix:system |
| 49 |
(format nil "sdump -s ~A ~A -r ~S,~S,~S,~S -o ~S,~S > ~A" |
| 50 |
scale (if direction "-d" "") |
| 51 |
(1- x) (1- y) (+ x wx) (+ y wy) |
| 52 |
(vector-x offset) (vector-y offset) |
| 53 |
fname))) |
| 54 |
|
| 55 |
(defun find-file (dir-list name) |
| 56 |
(cond |
| 57 |
((probe-file name) name) |
| 58 |
((null dir-list) |
| 59 |
(if (probe-file name) name "")) |
| 60 |
((atom dir-list) |
| 61 |
(find-file (list (string dir-list)) name)) |
| 62 |
(t |
| 63 |
(find-file (cdr dir-list) |
| 64 |
(concatenate string |
| 65 |
(string (car dir-list)) |
| 66 |
"/" name))))) |
| 67 |
;;; |
| 68 |
(defun mouse-status (window e) |
| 69 |
(when |
| 70 |
window |
| 71 |
(let* ((id (event_id e)) |
| 72 |
(we (send window :window_event e))) |
| 73 |
;; button: left, middle, right, nil |
| 74 |
;; movement: move, up, down, drag, still, |
| 75 |
;; winenter, winexit, rgnenter, rgnexit, nil |
| 76 |
(cond |
| 77 |
((equal id loc_move) |
| 78 |
(send (window . mouse) :current-movement 'move) |
| 79 |
(send (window . mouse) :current-button nil)) |
| 80 |
((equal id ms_left) (send (window . mouse) :current-button 'left)) |
| 81 |
((equal id ms_middle) (send (window . mouse) :current-button 'middle)) |
| 82 |
((equal id ms_right) (send (window . mouse) :current-button 'right)) |
| 83 |
((equal id loc_drag) |
| 84 |
(send (window . mouse) :current-button |
| 85 |
(send (window . mouse) :last-button)) |
| 86 |
(send (window . mouse) :current-movement 'drag)) |
| 87 |
((equal id loc_winenter) |
| 88 |
(send (window . mouse) :current-movement 'winenter)) |
| 89 |
((equal id loc_winexit) |
| 90 |
(send (window . mouse) :current-movement 'winexit)) |
| 91 |
) |
| 92 |
(when |
| 93 |
(event_is_button we) |
| 94 |
(cond |
| 95 |
((event_is_up we) (send (window . mouse) :current-movement 'up)) |
| 96 |
((event_is_down we) |
| 97 |
(send (window . mouse) :last-button |
| 98 |
(send (window . mouse) :current-button)) |
| 99 |
(send (window . mouse) :current-movement 'down)))) |
| 100 |
(prog1 |
| 101 |
(send (window . mouse) :status) |
| 102 |
(send (window . mouse) :last-movement |
| 103 |
(send (window . mouse) :current-movement))) |
| 104 |
))) |
| 105 |
|
| 106 |
(defun return-event nil (throw 'c-callable-proc nil)) |
| 107 |
|
| 108 |
(defmacro defwindow (name &key slots |
| 109 |
(super 'object) |
| 110 |
(size -1) |
| 111 |
((:metaclass metaklass) nil) |
| 112 |
element-type ) |
| 113 |
(let ((methods |
| 114 |
(append |
| 115 |
(mapcar #'(lambda (x) |
| 116 |
(list |
| 117 |
(read-from-string (format nil ":~a" x)) |
| 118 |
'(&rest args) |
| 119 |
`(if args |
| 120 |
(apply #'send (cons ,x args)) |
| 121 |
,x))) |
| 122 |
slots) |
| 123 |
(mapcar #'(lambda (x) |
| 124 |
(list |
| 125 |
(read-from-string (format nil ":set-~a" x)) |
| 126 |
'(v) |
| 127 |
`(setq ,x v))) |
| 128 |
slots))) |
| 129 |
) |
| 130 |
`(progn |
| 131 |
(make-class ',name |
| 132 |
:super ,super |
| 133 |
:slots ',slots |
| 134 |
:metaclass ,metaklass |
| 135 |
:element-type ,element-type |
| 136 |
:size ,size) |
| 137 |
(defmethod ,name |
| 138 |
,@methods) |
| 139 |
) |
| 140 |
)) |
| 141 |
|
| 142 |
(eval-when |
| 143 |
(compile load eval) |
| 144 |
(defun _2- (str) |
| 145 |
(nsubstitute #\- #\_ str)) |
| 146 |
(defmacro def-sunview-set-method (class |
| 147 |
attr |
| 148 |
&optional (head "WIN_")) |
| 149 |
(let ((selector (intern (_2- (string attr)) 'keyword)) |
| 150 |
(attr-key (intern |
| 151 |
(concatenate string (string head) (string attr)))) |
| 152 |
(setfunc |
| 153 |
(intern |
| 154 |
(if (equal head "WIN_") "WINDOW_SET" "PANEL_SET"))) |
| 155 |
) |
| 156 |
`(defmethod ,class |
| 157 |
(,selector |
| 158 |
(val) |
| 159 |
(,setfunc system-cadr ,attr-key val))) |
| 160 |
)) |
| 161 |
;;; |
| 162 |
(defmacro sunview-set-get-method (class |
| 163 |
attr |
| 164 |
&optional (head "WIN_")) |
| 165 |
(let* ((selector (intern (_2- (string attr)) 'keyword)) |
| 166 |
(attr-key (intern |
| 167 |
(concatenate string head (string attr)))) |
| 168 |
(setfunc |
| 169 |
(intern |
| 170 |
(if (equal head "WIN_") "WINDOW_SET" "PANEL_SET"))) |
| 171 |
(getfunc |
| 172 |
(intern |
| 173 |
(if (equal head "WIN_") "WINDOW_GET" "PANEL_GET"))) |
| 174 |
) |
| 175 |
`(defmethod ,class |
| 176 |
(,selector |
| 177 |
(&optional val) |
| 178 |
(cond |
| 179 |
(val |
| 180 |
(,setfunc system-cadr ,attr-key val)) |
| 181 |
(t (,getfunc system-cadr ,attr-key))))) |
| 182 |
)) |
| 183 |
|
| 184 |
) |
| 185 |
|
| 186 |
;;; |
| 187 |
(eval-when |
| 188 |
(compile load eval) |
| 189 |
(defun make-c-callable-function (args) |
| 190 |
(cond |
| 191 |
((listp args) |
| 192 |
(if (eq (car args) 'lisp:lambda-closure) |
| 193 |
(setq args (cddr args)) |
| 194 |
(setq args (cdr args)) |
| 195 |
)) |
| 196 |
((derivedp args closure) (setq args (cddr (args . code))))) |
| 197 |
(let* ((param (car args)) |
| 198 |
(bod (cdr args)) |
| 199 |
(paramspecs (mapcar #'(lambda (x) :integer) param)) |
| 200 |
(paramsyms (mapcar #'(lambda (x) (if (atom x) x (car x))) |
| 201 |
param)) |
| 202 |
(sym (gensym))) |
| 203 |
(unintern sym) |
| 204 |
(send (let ((symbol foreign-pod)) |
| 205 |
(intern (string sym) *package* )) |
| 206 |
:init paramspecs |
| 207 |
:integer |
| 208 |
`(lambda ,paramsyms |
| 209 |
(catch 'c-callable-proc . ,bod))) |
| 210 |
)) |
| 211 |
;;; |
| 212 |
(defun make-panel-notify-function () |
| 213 |
(make-c-callable-function |
| 214 |
'(lambda (item-cadr event-or-value event) |
| 215 |
(throw |
| 216 |
'c-callable-proc |
| 217 |
(let* |
| 218 |
((panel-cadr (panel_get item-cadr panel_parent_panel)) |
| 219 |
(panel (window-cadr-to-object panel-cadr)) |
| 220 |
(item (cdr (assq item-cadr (panel . item-object-list)))) |
| 221 |
(handler (item . notify-handler))) |
| 222 |
(cond |
| 223 |
((null handler)) |
| 224 |
((keywordp handler) |
| 225 |
(classcase |
| 226 |
item |
| 227 |
(panel-button-item |
| 228 |
(funcall #'send-window panel handler item event)) |
| 229 |
((panel-choice-item panel-cycle-item panel-toggle-item) |
| 230 |
(send-window |
| 231 |
panel handler |
| 232 |
(send item :choice (panel_get item-cadr panel_value)) |
| 233 |
item event)) |
| 234 |
(panel-slider-item |
| 235 |
(send-window panel handler event-or-value item event)) |
| 236 |
(panel-text-item |
| 237 |
(send-window panel handler |
| 238 |
(adr_to_string (panel_get item-cadr panel_value)) |
| 239 |
item event)))) |
| 240 |
(t |
| 241 |
(classcase |
| 242 |
item |
| 243 |
(panel-button-item (funcall handler item event)) |
| 244 |
((panel-choice-item panel-cycle-item panel-toggle-item) |
| 245 |
(funcall handler |
| 246 |
(send item :choice (panel_get item-cadr panel_value)) |
| 247 |
item event)) |
| 248 |
(panel-slider-item (funcall handler event-or-value item event)) |
| 249 |
(panel-text-item |
| 250 |
(funcall handler |
| 251 |
(adr_to_string (panel_get item-cadr panel_value)) |
| 252 |
item event))))) |
| 253 |
)))) |
| 254 |
) |
| 255 |
(defun send-window (window |
| 256 |
method |
| 257 |
&rest args) |
| 258 |
(cond |
| 259 |
((null window) (warn "~s not defined" method)) |
| 260 |
((find-method window method) |
| 261 |
(apply #'send (cons window (cons method args)))) |
| 262 |
(t |
| 263 |
(apply #'send-window |
| 264 |
(cons |
| 265 |
(send window :parent) |
| 266 |
(cons method args)))))) |
| 267 |
;;; |
| 268 |
(defun widget-event-function (widget event args) |
| 269 |
(throw |
| 270 |
'c-callable-proc |
| 271 |
(when |
| 272 |
widget |
| 273 |
(let* |
| 274 |
((mouse-status (mouse-status widget event)) |
| 275 |
(we (send widget :window_event event)) |
| 276 |
(element |
| 277 |
(assq mouse-status (widget . event-handler-list))) |
| 278 |
handler) |
| 279 |
(cond |
| 280 |
((and |
| 281 |
(widget . menu) |
| 282 |
(equal (event_id event) ms_right) |
| 283 |
(event_is_down event)) |
| 284 |
(send-window |
| 285 |
widget |
| 286 |
(cdr (assq 'menu (widget . event-handler-list))) |
| 287 |
(send-window widget :menu-show event))) |
| 288 |
((keywordp (setq handler (cdr element))) |
| 289 |
(send-window |
| 290 |
widget handler |
| 291 |
widget ;; widget |
| 292 |
(car element) ;; movement |
| 293 |
(send (widget . mouse) :current-button) ;; button |
| 294 |
(float-vector (event_x we) (event_y we)) ;; pos |
| 295 |
(event_time we))) ;; time |
| 296 |
(handler |
| 297 |
(funcall handler |
| 298 |
widget ;; widget |
| 299 |
(car element) ;; movement |
| 300 |
(send (widget . mouse) :current-button) ;; button |
| 301 |
(float-vector (event_x we) (event_y we)) ;;pos |
| 302 |
(event_time we) ;; time |
| 303 |
)) |
| 304 |
((derivedp widget panel-item) |
| 305 |
(panel_default_handle_event (widget . system-cadr) event)) |
| 306 |
)) |
| 307 |
))) |
| 308 |
(defparameter *window-event-function* |
| 309 |
(make-c-callable-function |
| 310 |
'(lambda (cadr event args) |
| 311 |
(widget-event-function (window-cadr-to-object cadr) event args)))) |
| 312 |
(defparameter *item-event-function* |
| 313 |
(make-c-callable-function |
| 314 |
'(lambda (cadr event args) |
| 315 |
(widget-event-function (item-cadr-to-object cadr) event args)))) |
| 316 |
(defparameter *panel-notify-function* (make-panel-notify-function)) |
| 317 |
(defparameter *window-itimer-function* |
| 318 |
(make-c-callable-function |
| 319 |
'(lambda (client type) |
| 320 |
(throw 'c-callable-proc |
| 321 |
(let* ((window (window-cadr-to-object client))) |
| 322 |
(when |
| 323 |
window |
| 324 |
(let ((itimer-handler (send window :itimer))) |
| 325 |
(cond |
| 326 |
((null itimer-handler)) |
| 327 |
((keywordp itimer-handler) |
| 328 |
(send window itimer-handler window type)) |
| 329 |
(t (funcall itimer-handler window type)))))))))) |
| 330 |
(defparameter *canvas-repaint-function* |
| 331 |
(make-c-callable-function |
| 332 |
'(lambda (client pixwin repaint-area) |
| 333 |
(throw 'c-callable-proc |
| 334 |
(let* ((window (window-cadr-to-object client))) |
| 335 |
(when |
| 336 |
window |
| 337 |
(let ((repaint-handler (window . repaint-handler))) |
| 338 |
(cond |
| 339 |
((null repaint-handler)) |
| 340 |
((keywordp repaint-handler) |
| 341 |
(send-window window repaint-handler |
| 342 |
window pixwin repaint-area)) |
| 343 |
(t (funcall repaint-handler window |
| 344 |
pixwin repaint-area)))))))))) |
| 345 |
(defparameter *canvas-resize-function* |
| 346 |
(make-c-callable-function |
| 347 |
'(lambda (client width height) |
| 348 |
(throw 'c-callable-proc |
| 349 |
(let* ((window (window-cadr-to-object client))) |
| 350 |
(when |
| 351 |
window |
| 352 |
(let ((resize-handler (window . resize-handler))) |
| 353 |
(cond |
| 354 |
((null resize-handler)) |
| 355 |
((keywordp resize-handler) |
| 356 |
(send-window window resize-handler |
| 357 |
window width height)) |
| 358 |
(t (funcall resize-handler window width height)))))))))) |
| 359 |
(defparameter *item-itimer-function* |
| 360 |
(make-c-callable-function |
| 361 |
'(lambda (client type) |
| 362 |
(let* ((item (item-cadr-to-object client))) |
| 363 |
(when |
| 364 |
item |
| 365 |
(let ((itimer-handler (send item :itimer))) |
| 366 |
(cond |
| 367 |
((null itimer-handler)) |
| 368 |
((keywordp itimer-handler) |
| 369 |
(send item itimer-handler item type)) |
| 370 |
(t (funcall itimer-handler item type))))))))) |
| 371 |
) |
| 372 |
;;; |
| 373 |
(defun 4byte-string-to-long (str) (sys:peek str 0 :long) |
| 374 |
#| (let ((v 0)) |
| 375 |
(dotimes (i 4 v) |
| 376 |
(setq v (+ (* 256 v) (elt str i)))) ) |# |
| 377 |
) |
| 378 |
(defun long-to-4byte-string (v) |
| 379 |
(sys:poke v (make-string 4) 0 :long) |
| 380 |
#| (let ((str (make-string 4))) |
| 381 |
(dotimes (i 4 str) |
| 382 |
(setf (aref str (- 3 i)) (logand v #xff)) |
| 383 |
(setq v (ash v -8))) |
| 384 |
) |# |
| 385 |
) |
| 386 |
(defun itimer-string (sec) |
| 387 |
(let |
| 388 |
((str |
| 389 |
(concatenate |
| 390 |
string |
| 391 |
(long-to-4byte-string (floor sec)) |
| 392 |
(long-to-4byte-string (floor (* (- sec (floor sec)) |
| 393 |
1000000)))))) |
| 394 |
(concatenate string str str))) |
| 395 |
(defun icon-image (name) |
| 396 |
(setq name (find-file *icon-directories* name)) |
| 397 |
(icon_load_mpr name (make-string 100))) |
| 398 |
|
| 399 |
(defmethod sunview-mouse |
| 400 |
(:current-button (&optional v) |
| 401 |
(if v (setq current-button v) current-button)) |
| 402 |
(:current-movement (&optional v) |
| 403 |
(if v (setq current-movement v) current-movement)) |
| 404 |
(:last-button (&optional v) |
| 405 |
(if v (setq last-button v) last-button)) |
| 406 |
(:last-movement (&optional v) |
| 407 |
(if v (setq last-movement v) last-movement)) |
| 408 |
(:status () |
| 409 |
(case |
| 410 |
last-movement |
| 411 |
(up |
| 412 |
(case current-movement |
| 413 |
(move 'moving) |
| 414 |
(down 'pressed-again))) |
| 415 |
(down |
| 416 |
(case current-movement |
| 417 |
(up 'clicked) |
| 418 |
((drag still move down) 'drag-started))) |
| 419 |
(drag |
| 420 |
(case current-movement |
| 421 |
(up 'drag-finished) |
| 422 |
((drag still move) 'dragging))) |
| 423 |
(move |
| 424 |
(case current-movement |
| 425 |
((move still) 'moving) |
| 426 |
(down 'moving))) |
| 427 |
(still |
| 428 |
(case current-movement |
| 429 |
(move 'moving) |
| 430 |
(drag 'dragging) |
| 431 |
(up 'drag-finished) |
| 432 |
(down 'moving))) |
| 433 |
)) |
| 434 |
(:init (&key |
| 435 |
((:current-movement cm)) |
| 436 |
((:current-button cb))) |
| 437 |
(setq current-movement cm current-button cb) |
| 438 |
(setq last-movement nil last-button nil) |
| 439 |
self)) |
| 440 |
|
| 441 |
(defmethod sunview-object |
| 442 |
(:cadr (&optional adr) |
| 443 |
(if adr |
| 444 |
(setq system-cadr adr) |
| 445 |
system-cadr)) |
| 446 |
(:init (&rest l &key ((:system-cadr s)) &allow-other-keys) |
| 447 |
(if s (setq system-cadr s)) |
| 448 |
self) ) |
| 449 |
|
| 450 |
(defmethod sunview-widget |
| 451 |
(:parent (&optional v) |
| 452 |
(if v (setq parent v) parent)) |
| 453 |
(:ancestor () |
| 454 |
(cond |
| 455 |
((null (send self :parent)) self) |
| 456 |
(t (send (send self :parent) :ancestor)))) |
| 457 |
;;; (:name (v) (send self :title v)) |
| 458 |
(:show (&optional (f t)) |
| 459 |
(send self :fit) |
| 460 |
(send self :show f)) |
| 461 |
(:menu (&optional v) |
| 462 |
(cond |
| 463 |
(v |
| 464 |
(setq menu v)) |
| 465 |
(menu menu) |
| 466 |
(t (setq menu (instance sunview-menu :init self)))) |
| 467 |
menu) |
| 468 |
;;; |
| 469 |
(:clicked-proc (method) |
| 470 |
(send self :enter-handler 'clicked method)) |
| 471 |
(:moving-proc (method) |
| 472 |
(send self :enter-handler 'moving method)) |
| 473 |
(:dragging-proc (method) |
| 474 |
(send self :enter-handler 'dragging method)) |
| 475 |
(:drag-started-proc (method) |
| 476 |
(send self :enter-handler 'drag-started method)) |
| 477 |
(:drag-finished-proc (method) |
| 478 |
(send self :enter-handler 'drag-finished method)) |
| 479 |
;; sunview-widget |
| 480 |
(:init (&rest l &key ((:menu m)) |
| 481 |
((:font f)) |
| 482 |
clicked-proc moving-proc |
| 483 |
dragging-proc drag-started-proc |
| 484 |
drag-finished-proc |
| 485 |
eproc |
| 486 |
&allow-other-keys) |
| 487 |
(apply #'send-message self (class . super) :init l) |
| 488 |
(if m (send self :menu m)) |
| 489 |
(send self :font f) |
| 490 |
(setq mouse (instance sunview-mouse :init)) |
| 491 |
(if eproc (send self :set-eproc (make-c-callable-function eproc))) |
| 492 |
(send self :enter-handler 'clicked clicked-proc) |
| 493 |
(send self :enter-handler 'moving moving-proc) |
| 494 |
(send self :enter-handler 'dragging dragging-proc) |
| 495 |
(send self :enter-handler 'drag-finished drag-finished-proc) |
| 496 |
(send self :enter-handler 'drag-started drag-started-proc) |
| 497 |
self) |
| 498 |
) |
| 499 |
;;; |
| 500 |
(defmethod sunview-window |
| 501 |
(:hardcopy |
| 502 |
(&optional |
| 503 |
(value (format nil "window~A.ps" system-cadr)) |
| 504 |
&key (scale 3) (direction nil) |
| 505 |
(offset #f(1.0 1.0))) ;;; inches |
| 506 |
(hardcopy value :scale scale :direction direction |
| 507 |
:offset offset |
| 508 |
:x (send self :x) :y (send self :y) |
| 509 |
:wx (send self :wx) :wy (send self :wy))) |
| 510 |
(:itimer () itimer-handler) |
| 511 |
(:set-itimer-period |
| 512 |
(v) (send self :set-itimer itimer-handler :period v)) |
| 513 |
(:set-itimer (func &key (type itimer_real) |
| 514 |
(period 0.1)) ;; sec |
| 515 |
(setq itimer-handler func) |
| 516 |
(notify_set_itimer_func |
| 517 |
system-cadr (send *window-itimer-function* :pod-address) |
| 518 |
type |
| 519 |
(itimer-string period) |
| 520 |
0)) |
| 521 |
(:stop-itimer (&optional (type itimer_real)) |
| 522 |
(notify_set_itimer_func |
| 523 |
system-cadr (send *window-itimer-function* :pod-address) |
| 524 |
type 0 0)) |
| 525 |
(:menu-show (event) |
| 526 |
(let ((k 0)) |
| 527 |
(if (derivedp menu sunview-menu) |
| 528 |
(setq k (menu_show (menu . system-cadr) |
| 529 |
system-cadr |
| 530 |
event))) |
| 531 |
(if (eq k 0) nil |
| 532 |
(send menu :choice (1- k))))) |
| 533 |
(:clear () |
| 534 |
(pr_rop (send self :pixwin) |
| 535 |
0 0 |
| 536 |
(send self :width) (send self :height) |
| 537 |
pix_clr 0 0 0)) |
| 538 |
(:drawpolygon (points &key (op pix_set) |
| 539 |
(x 0) (y 0) |
| 540 |
(pixwin (send self :pixwin)) |
| 541 |
(rect 0) (sx 0) (sy 0)) |
| 542 |
(pw_polygon_2 pixwin x y |
| 543 |
1 |
| 544 |
(vector (length points)) |
| 545 |
points op rect sx sy)) |
| 546 |
(:drawpolyline (points &key (op pix_set) |
| 547 |
(pixwin (send self :pixwin)) |
| 548 |
(x 0) (y 0) |
| 549 |
(mvlist 0) (brush 0) (texture 0)) |
| 550 |
(pw_polyline pixwin x y |
| 551 |
(length points) |
| 552 |
points mvlist |
| 553 |
brush texture op)) |
| 554 |
(:drawimage (imagestring |
| 555 |
&key (x 0) (y 0) (size 256) (width size) (height size) |
| 556 |
(depth 8) (op pix_src) |
| 557 |
(pixwin (send self :pixwin)) |
| 558 |
(pixrect (if (equal "" imagestring) |
| 559 |
0 |
| 560 |
(mem_point width height depth imagestring))) |
| 561 |
(pixrect-x 0) (pixrect-y 0)) |
| 562 |
(pw_rop pixwin x y width height op pixrect pixrect-x pixrect-y)) |
| 563 |
(:drawtext |
| 564 |
(textstring x0 y0 &key (font 0) (op pix_src) |
| 565 |
(pixwin (send self :pixwin))) |
| 566 |
(pw_text pixwin x0 y0 op font |
| 567 |
(string-body-address textstring))) |
| 568 |
(:drawttext |
| 569 |
(textstring x0 y0 &key (font 0) (op pix_src) |
| 570 |
(pixwin (send self :pixwin))) |
| 571 |
(pw_ttext pixwin x0 y0 op font |
| 572 |
(string-body-address textstring))) |
| 573 |
(:drawline |
| 574 |
(x0 y0 x1 y1 &key (op pix_src) (color 1) (pixwin (send self :pixwin))) |
| 575 |
(pw_vector pixwin x0 y0 x1 y1 op color)) |
| 576 |
(:imagemove (&key (from (float-vector 0 0)) |
| 577 |
(to (float-vector 0 0)) |
| 578 |
(pixwin (send self :pixwin)) |
| 579 |
(op pix_src)) |
| 580 |
(let ((width (send self :width)) |
| 581 |
(height (send self :height))) |
| 582 |
(pw_copy pixwin to width height op pixwin from) |
| 583 |
)) |
| 584 |
(:cmssize () |
| 585 |
(length (car (send self :get-colormap)))) |
| 586 |
(:cmsname |
| 587 |
(&optional v) |
| 588 |
(if v (pw_setcmsname (send self :pixwin) v) |
| 589 |
(pw_getcmsname (send self :pixwin)))) |
| 590 |
(:put-colormap |
| 591 |
(&optional (r (coerce '(0 255) string)) |
| 592 |
(g (coerce '(0 255) string)) |
| 593 |
(b (coerce '(0 255) string)) |
| 594 |
(index 0) |
| 595 |
(count 2)) |
| 596 |
(pw_putcolormap (send self :pixwin) index count r g b) |
| 597 |
) |
| 598 |
(:get-colormap () |
| 599 |
(pw_getcolormap (send self :pixwin)) ) |
| 600 |
(:pixwin () (window_get system-cadr win_pixwin)) |
| 601 |
(:enter-handler (mouse-status method) |
| 602 |
;; method , function |
| 603 |
(when method |
| 604 |
(push (cons mouse-status method) event-handler-list) |
| 605 |
(send self :set-eproc *window-event-function*)) ) |
| 606 |
(:set-eproc (proc) |
| 607 |
(window_set |
| 608 |
system-cadr win_event_proc (send proc :pod-address))) |
| 609 |
(:font (&optional (f t)) |
| 610 |
(cond |
| 611 |
((numberp f) |
| 612 |
(window_set system-cadr win_font (setq font f))) |
| 613 |
((stringp f) |
| 614 |
(window_set system-cadr win_font (setq font (pf_open f)))) |
| 615 |
((eq f t)) |
| 616 |
(t (setq font 0))) |
| 617 |
font) |
| 618 |
(:set (&rest l) (window_set system-cadr l)) |
| 619 |
(:fit () |
| 620 |
(if subwindows (send (car subwindows) :fit)) |
| 621 |
(send self :fit-height) |
| 622 |
(send self :fit-width) |
| 623 |
) |
| 624 |
(:fit-height () |
| 625 |
(send self :height (send self :height)) |
| 626 |
(window_fit_height system-cadr)) |
| 627 |
(:fit-width () |
| 628 |
(send self :width (send self :width)) |
| 629 |
(window_fit_width system-cadr)) |
| 630 |
(:destroy () (window_destroy system-cadr)) |
| 631 |
(:show (&optional (flag t)) |
| 632 |
(cond |
| 633 |
(flag (setq flag true) |
| 634 |
(send self :fit)) |
| 635 |
(t (setq flag null))) |
| 636 |
(window_set system-cadr win_show flag) |
| 637 |
(notify_do_dispatch) |
| 638 |
) |
| 639 |
;;; |
| 640 |
(:create-subwindow |
| 641 |
(cls &rest args &key &allow-other-keys) |
| 642 |
(if subwindows (send (car subwindows) :fit)) |
| 643 |
(push |
| 644 |
(apply #'send (instantiate cls) :init self args) |
| 645 |
subwindows) |
| 646 |
(car subwindows)) |
| 647 |
;;; |
| 648 |
(:create-item |
| 649 |
(cls &rest args) |
| 650 |
(let* |
| 651 |
((window (or (car subwindows) self)) |
| 652 |
(item (apply #'send (instantiate cls) :init window args))) |
| 653 |
(send window :item-row |
| 654 |
(+ (send window :item-row) (send item :row-offset))) |
| 655 |
(send item :row) |
| 656 |
item)) |
| 657 |
(:create-item-with-method |
| 658 |
(cls method &rest args) |
| 659 |
(apply #'send self :create-item cls (cons :nproc (cons method args)))) |
| 660 |
(:create-slider |
| 661 |
(method &rest args) |
| 662 |
(apply #'send self :create-item-with-method panel-slider-item method args)) |
| 663 |
(:create-text |
| 664 |
(method &rest args) |
| 665 |
(apply #'send self :create-item-with-method panel-text-item method args)) |
| 666 |
(:create-choice |
| 667 |
(method &rest args) |
| 668 |
(apply #'send self :create-item-with-method panel-choice-item method args)) |
| 669 |
(:create-cycle |
| 670 |
(method &rest args) |
| 671 |
(apply #'send self :create-item-with-method panel-cycle-item method args)) |
| 672 |
(:create-toggle |
| 673 |
(method &rest args) |
| 674 |
(apply #'send self :create-item-with-method panel-toggle-item method args)) |
| 675 |
(:create-message |
| 676 |
(&rest args) |
| 677 |
(apply #'send self :create-item panel-message-item args)) |
| 678 |
(:create-button |
| 679 |
(method &rest args) |
| 680 |
(apply #'send self :create-item-with-method panel-button-item method args)) |
| 681 |
(:below (w) |
| 682 |
(window_set system-cadr win_below (w . system-cadr))) |
| 683 |
(:right-of (w) |
| 684 |
(window_set system-cadr win_right_of (w . system-cadr))) |
| 685 |
;;; sunview-window |
| 686 |
(:init (&rest l &key |
| 687 |
((:title nam)) |
| 688 |
x y width height below right-of |
| 689 |
&allow-other-keys) |
| 690 |
(push (cons system-cadr self) xview-directory) |
| 691 |
(if x (send self :x x)) |
| 692 |
(if y (send self :y y)) |
| 693 |
(if width (send self :width width)) |
| 694 |
(if height (send self :height height)) |
| 695 |
(if below (send self :below below)) |
| 696 |
(if right-of (send self :right-of right-of)) |
| 697 |
(apply #'send-message self (class . super) :init l) |
| 698 |
self |
| 699 |
) |
| 700 |
) |
| 701 |
;;; |
| 702 |
(defmethod sunview-frame |
| 703 |
(:window_event (e) e) |
| 704 |
(:title (&optional v) |
| 705 |
(if v |
| 706 |
(window_set system-cadr frame_label (setq name v)) |
| 707 |
name)) |
| 708 |
(:icon (&optional v) |
| 709 |
(cond |
| 710 |
((and v (setq v (find-file *icon-directories* v))) |
| 711 |
(window_set system-cadr frame_icon |
| 712 |
(icon_create icon_image (icon-image (setq icon v)) 0))) |
| 713 |
(t icon) |
| 714 |
)) |
| 715 |
;;; sunview-frame |
| 716 |
(:init (&optional (par nil) |
| 717 |
&rest args |
| 718 |
&key |
| 719 |
((:title nam) "") |
| 720 |
((:icon v)) |
| 721 |
&allow-other-keys) |
| 722 |
(notify_no_dispatch) |
| 723 |
(cond |
| 724 |
((derivedp par sunview-window) |
| 725 |
(cond |
| 726 |
((numberp (par . system-cadr)) |
| 727 |
(setq parent par) |
| 728 |
(setq system-cadr (par . system-cadr))) |
| 729 |
(t (setq parent par) |
| 730 |
(setq system-cadr (window_create_frame 0)) |
| 731 |
(setq (par . system-cadr) system-cadr)) |
| 732 |
)) |
| 733 |
((numberp par) |
| 734 |
(setq system-cadr (window_create_frame par)) |
| 735 |
(setq parent (window-cadr-to-object par))) |
| 736 |
(t (setq parent nil) |
| 737 |
(setq system-cadr (window_create_frame 0)))) |
| 738 |
(apply #'send-message self (class . super) :init args) |
| 739 |
(send self :title nam) |
| 740 |
(send self :icon v) |
| 741 |
;;; (notify_do_dispatch) |
| 742 |
self) |
| 743 |
) |
| 744 |
;;; |
| 745 |
(defmethod sunview-panel |
| 746 |
(:push-item-object-list (cadr object) |
| 747 |
(push (cons cadr object) item-object-list)) |
| 748 |
(:event (e) (panel_event system-cadr e)) |
| 749 |
(:window_event (e) (panel_window_event system-cadr e)) |
| 750 |
(:item-size (&optional v) (if v (setq item-size v) item-size)) |
| 751 |
(:col-max (&optional v) (if v (setq col-max v) col-max)) |
| 752 |
(:col-num (&optional v) (if v (setq col-max (1- v)) (1+ col-max))) |
| 753 |
(:layout (&optional v) |
| 754 |
(cond |
| 755 |
(v (window_set system-cadr panel_layout v)) |
| 756 |
(t (window_get system-cadr panel_layout)))) |
| 757 |
(:horizontal (&optional (flag 0)) |
| 758 |
(cond |
| 759 |
((eq flag 0) |
| 760 |
(equal (send self :layout) panel_horizontal)) |
| 761 |
((null flag) |
| 762 |
(send self :layout panel_vertical)) |
| 763 |
(t (send self :layout panel_horizontal)))) |
| 764 |
(:vertical (&optional (flag 0)) |
| 765 |
(cond |
| 766 |
((eq flag 0) |
| 767 |
(equal (send self :layout) panel_vertical)) |
| 768 |
((null flag) |
| 769 |
(send self :layout panel_horizontal)) |
| 770 |
(t (send self :layout panel_vertical)))) |
| 771 |
(:item-col (&optional v) |
| 772 |
(cond |
| 773 |
((numberp v) |
| 774 |
(setq item-col v) |
| 775 |
(if (= v 0) (setq item-row (1+ item-row)))) |
| 776 |
(t (setq item-col (1+ item-col)))) |
| 777 |
(if |
| 778 |
(> item-col col-max) |
| 779 |
(setq item-col 0 item-row (1+ item-row))) |
| 780 |
item-col) |
| 781 |
(:item-row (&optional v) |
| 782 |
(if (numberp v) (setq item-row v) item-row)) |
| 783 |
;; panel |
| 784 |
(:init (&optional par |
| 785 |
&rest args &key |
| 786 |
vertical horizontal |
| 787 |
(scrollbar t) |
| 788 |
((:item-size is) 20) |
| 789 |
((:col-num cs) 1) |
| 790 |
((:col-max cm) 0) |
| 791 |
&allow-other-keys) |
| 792 |
(setq item-col -1 item-row 0) |
| 793 |
(setq item-size is col-max cm) |
| 794 |
(when (null par) |
| 795 |
(setq par (instantiate sunview-frame)) |
| 796 |
(apply #'send (cons par (cons :init args)))) |
| 797 |
(send self :parent par) |
| 798 |
(setq system-cadr (window_create_panel (send parent :cadr))) |
| 799 |
|
| 800 |
(if (memq scrollbar '(t vertical v)) |
| 801 |
(panel_set system-cadr |
| 802 |
win_vertical_scrollbar |
| 803 |
(scrollbar_create 0))) |
| 804 |
(if (memq scrollbar '(t horizontal h)) |
| 805 |
(panel_set system-cadr |
| 806 |
win_horizontal_scrollbar |
| 807 |
(scrollbar_create 0))) |
| 808 |
(if scrollbar (panel_update_scrolling_size system-cadr)) |
| 809 |
(if vertical |
| 810 |
(panel_set system-cadr panel_layout panel_vertical)) |
| 811 |
(if horizontal |
| 812 |
(panel_set system-cadr panel_layout panel_horizontal)) |
| 813 |
(apply #'send-message self (class . super) :init args) |
| 814 |
self) |
| 815 |
) |
| 816 |
;;; |
| 817 |
|
| 818 |
(defmethod sunview-canvas |
| 819 |
(:clear () |
| 820 |
(let ((width (send self :width)) (height (send self :height)) |
| 821 |
(pixwindow (send self :pixwin))) |
| 822 |
(pw_writebackground pixwindow 0 0 width height pix_clr))) |
| 823 |
(:set-eproc (proc) |
| 824 |
(window_set |
| 825 |
(canvas_paint_window system-cadr) |
| 826 |
win_event_proc (send proc :pod-address))) |
| 827 |
(:repaint-proc (method) |
| 828 |
(when |
| 829 |
method |
| 830 |
(setq repaint-handler method) |
| 831 |
(window_set (canvas_paint_window system-cadr) canvas_repaint_proc |
| 832 |
(send *canvas-repaint-function* :pod-address)))) |
| 833 |
(:resize-proc (method) |
| 834 |
(when |
| 835 |
method |
| 836 |
(setq resize-handler method) |
| 837 |
(window_set (canvas_paint_window system-cadr) canvas_resize_proc |
| 838 |
(send *canvas-resize-function* :pod-address)))) |
| 839 |
(:pixwin () (canvas_pixwin system-cadr)) |
| 840 |
(:event (e) (canvas_event (canvas_paint_window system-cadr) e)) |
| 841 |
(:window_event (e) |
| 842 |
(canvas_window_event |
| 843 |
(canvas_paint_window system-cadr) |
| 844 |
e)) |
| 845 |
(:set-half-color |
| 846 |
() |
| 847 |
(let |
| 848 |
((r (make-string 256)) |
| 849 |
(g (make-string 256)) |
| 850 |
(b (make-string 256))) |
| 851 |
(send self :gpal r g b 0.01 0 50 0.2 0.7 1 8 16) |
| 852 |
(send self :gpal r g b 0.2 30 40 0.3 0.7 1 16 24) |
| 853 |
(send self :gpal r g b 0.27 50 60 0.3 0.7 1 24 32) |
| 854 |
(send self :gpal r g b 0.25 70 80 0.3 0.7 1 32 40) |
| 855 |
(send self :gpal r g b 0.2 110 120 0.3 0.7 1 40 48) |
| 856 |
(send self :gpal r g b 0.2 160 170 0.3 0.7 1 48 56) |
| 857 |
(send self :gpal r g b 0.2 190 200 0.3 0.7 1 56 64) |
| 858 |
(send self :gpal r g b 0.2 220 230 0.3 0.7 1 64 72) |
| 859 |
(send self :put-colormap r g b 8 (- 72 8)) |
| 860 |
)) |
| 861 |
(:set-vivid-color |
| 862 |
() |
| 863 |
(let |
| 864 |
((r (make-string 256)) |
| 865 |
(g (make-string 256)) |
| 866 |
(b (make-string 256))) |
| 867 |
(send self :gpal r g b 0.75 0 10 0.4 0.8 1 72 80) |
| 868 |
(send self :gpal r g b 0.75 30 40 0.2 0.8 1 80 88 ) |
| 869 |
(send self :gpal r g b 0.75 90 100 0.4 0.8 1 88 96) |
| 870 |
(send self :gpal r g b 0.75 180 190 0.2 0.6 1 96 104) |
| 871 |
(send self :gpal r g b 0.75 270 280 0.4 0.8 1 104 112) |
| 872 |
(send self :gpal r g b 0.75 320 340 0.3 0.7 1 112 120) |
| 873 |
(send self :put-colormap r g b 0 (- 120 72))) |
| 874 |
) |
| 875 |
(:gpal |
| 876 |
(red-cmap green-cmap blue-cmap |
| 877 |
sat h1 h2 dark bright &optional (group 1) (s 3) (e 64)) |
| 878 |
(let ((hinc (/ (- h2 h1) (- e s))) |
| 879 |
(linc (/ (- bright dark) (/ (- e s) group))) |
| 880 |
(hls 0) (l dark) ) |
| 881 |
(while (< s e) |
| 882 |
(setq hls (hls2rgb h1 l sat)) |
| 883 |
(setf (aref red-cmap s) (car hls)) |
| 884 |
(setf (aref green-cmap s) (cadr hls)) |
| 885 |
(setf (aref blue-cmap s) (caddr hls)) |
| 886 |
(inc s) |
| 887 |
(setq h1 (+ h1 hinc)) |
| 888 |
(setq l (+ l linc)) |
| 889 |
(cond ((or (> l bright) (< l dark)) (setq linc (- linc)))) |
| 890 |
) |
| 891 |
)) |
| 892 |
(:set-gray-color |
| 893 |
(&optional (offset 128) (scale 0.5)) |
| 894 |
(let ((cmap (make-string 256))) |
| 895 |
(do ((i 0 (1+ i))) |
| 896 |
((>= i 256)) |
| 897 |
(setf (aref cmap i) |
| 898 |
(round (+ offset (* i scale))))) |
| 899 |
(send self :put-colormap cmap cmap cmap 0 256))) |
| 900 |
(:set-mono-tone |
| 901 |
() |
| 902 |
(let ((cmap (coerce '(255 0) string))) |
| 903 |
(send self :put-colormap cmap cmap cmap 0 2) |
| 904 |
)) |
| 905 |
(:set-cmap-type |
| 906 |
(type) |
| 907 |
(case |
| 908 |
type |
| 909 |
((:gray :gray-cmap :gray-color) (send self :set-gray-color)) |
| 910 |
((:vivid :vivid-cmap :vivid-color) (send self :set-vivid-color)) |
| 911 |
((:half :half-tone :half-color) (send self :set-half-color)) |
| 912 |
((:mono :mono-tone :monochrome) (send self :set-mono-tone)))) |
| 913 |
;; canvas |
| 914 |
(:line-width (wid) nil) |
| 915 |
(:line-style (dash) nil) |
| 916 |
(:init (&optional par |
| 917 |
&rest args &key |
| 918 |
resize-proc |
| 919 |
repaint-proc |
| 920 |
&allow-other-keys) |
| 921 |
(when (null par) |
| 922 |
(setq par (instantiate sunview-frame)) |
| 923 |
(apply #'send (cons par (cons :init args)))) |
| 924 |
(send self :parent par) |
| 925 |
(setq system-cadr |
| 926 |
(window_create_canvas (send parent :cadr) |
| 927 |
win_dynamic_visual true)) |
| 928 |
(apply #'send-message self (class . super) :init args) |
| 929 |
(push (cons (canvas_paint_window system-cadr) self) |
| 930 |
xview-directory) |
| 931 |
(window_set (canvas_paint_window system-cadr) |
| 932 |
win_consume_pick_event win_up_events |
| 933 |
win_consume_pick_event win_mouse_buttons |
| 934 |
win_consume_pick_event loc_drag |
| 935 |
;;; win_consume_pick_event loc_move |
| 936 |
) |
| 937 |
(send self :repaint-proc repaint-proc) |
| 938 |
(send self :resize-proc resize-proc) |
| 939 |
self) |
| 940 |
) |
| 941 |
|
| 942 |
;;; |
| 943 |
(defmethod sunview-textsw |
| 944 |
(:set-selection |
| 945 |
(first last &optional (type 1)) ;;; 1:primary 2:secondary 17:pending |
| 946 |
(textsw_set_selection system-cadr first last type)) |
| 947 |
(:find-bytes-forward (buf index) (send self :find-bytes buf index 0)) |
| 948 |
(:find-bytes-backward (buf index) (send self :find-bytes buf index 1)) |
| 949 |
(:find-bytes |
| 950 |
(buf index &optional (direction 0)) |
| 951 |
(let ((first |
| 952 |
(long-to-4byte-string index)) |
| 953 |
(last (long-to-4byte-string 0))) |
| 954 |
(textsw_find_bytes system-cadr first last buf (length buf) direction) |
| 955 |
(list (4byte-string-to-long first) |
| 956 |
(4byte-string-to-long last)) |
| 957 |
)) |
| 958 |
(:match-bytes-forward |
| 959 |
(start-sym end-sym index) |
| 960 |
(send self :match-bytes start-sym end-sym index textsw_delimiter_forward)) |
| 961 |
(:match-bytes-backward |
| 962 |
(start-sym end-sym index) |
| 963 |
(send self :match-bytes start-sym end-sym index textsw_delimiter_backward)) |
| 964 |
(:match-bytes-enclose |
| 965 |
(start-sym end-sym index) |
| 966 |
(send self :match-bytes start-sym end-sym index)) |
| 967 |
(:match-bytes |
| 968 |
(start-sym end-sym index &optional (direction textsw_delimiter_enclose)) |
| 969 |
(let ((first |
| 970 |
(long-to-4byte-string index)) |
| 971 |
(last (long-to-4byte-string 0))) |
| 972 |
(textsw_match_bytes system-cadr |
| 973 |
first last |
| 974 |
start-sym (length start-sym) |
| 975 |
end-sym (length end-sym) |
| 976 |
direction) |
| 977 |
(list (4byte-string-to-long first) |
| 978 |
(4byte-string-to-long last)) |
| 979 |
)) |
| 980 |
(:first-line (&optional v) |
| 981 |
(if v (window_set system-cadr textsw_first_line v) |
| 982 |
(window_get system-cadr textsw_first_line))) |
| 983 |
(:first (&optional v) |
| 984 |
(if v (window_set system-cadr textsw_first v) |
| 985 |
(window_get system-cadr textsw_first))) |
| 986 |
(:index-for-file-line (line-no) |
| 987 |
(textsw_index_for_file_line system-cadr line-no)) |
| 988 |
(:normalize-view (charp) |
| 989 |
(textsw_normalize_view system-cadr charp)) |
| 990 |
(:possibly-normalize (charp) |
| 991 |
(textsw_possibly_normalize system-cadr charp)) |
| 992 |
(:last-point () |
| 993 |
(window_set system-cadr textsw_insertion_point textsw_infinity) |
| 994 |
(send self :insertion-point)) |
| 995 |
(:set-file-contents |
| 996 |
(fname &optional (pos 0)) |
| 997 |
(window_set system-cadr textsw_file_contents fname |
| 998 |
textsw_first pos)) |
| 999 |
(:set-contents (str &optional (pos 0)) |
| 1000 |
(window_set system-cadr textsw_contents str |
| 1001 |
textsw_first pos)) |
| 1002 |
(:get-contents (&optional (start 0) (end (send self :length))) |
| 1003 |
(let* ((len (- end start)) (buf (make-string len))) |
| 1004 |
(window_get system-cadr textsw_contents start buf len) |
| 1005 |
buf)) |
| 1006 |
(:insertion-point (&optional v) |
| 1007 |
(if v (window_set system-cadr textsw_insertion_point v)) |
| 1008 |
(window_get system-cadr textsw_insertion_point)) |
| 1009 |
(:insert (buf &optional (len (length buf))) |
| 1010 |
(textsw_insert system-cadr buf len)) |
| 1011 |
(:delete (first len) |
| 1012 |
(textsw_delete system-cadr first (+ first len))) |
| 1013 |
(:erase (first len) |
| 1014 |
(textsw_erase system-cadr first (+ first len))) |
| 1015 |
(:replace (first len buf &optional (blen (length buf))) |
| 1016 |
(textsw_replace_bytes system-cadr first (+ first len) |
| 1017 |
buf blen)) |
| 1018 |
(:flush () (send self :insert " |
| 1019 |
")) |
| 1020 |
(:scroll (count) (textsw_scroll_lines system-cadr count)) |
| 1021 |
(:screen-lines () (textsw_screen_line_count system-cadr)) |
| 1022 |
(:load (file-name &optional (position 0)) |
| 1023 |
(window_set system-cadr textsw_file file-name |
| 1024 |
textsw_first position)) |
| 1025 |
(:save (&optional (x 0) (y 0)) |
| 1026 |
(textsw_save system-cadr x y)) |
| 1027 |
(:store (file-name &optional (x 0) (y 0)) |
| 1028 |
(textsw_store_file system-cadr file-name x y)) |
| 1029 |
(:reset (&optional (x 0) (y 0)) |
| 1030 |
(textsw_reset system-cadr x y)) |
| 1031 |
(:length () |
| 1032 |
(window_get system-cadr textsw_length)) |
| 1033 |
;; textsw |
| 1034 |
(:init (&optional par |
| 1035 |
&rest args &key &allow-other-keys) |
| 1036 |
(when (null par) |
| 1037 |
(setq par (instantiate sunview-frame)) |
| 1038 |
(apply #'send (cons par (cons :init args)))) |
| 1039 |
(send self :parent par) |
| 1040 |
(setq system-cadr (window_create_textsw |
| 1041 |
(send parent :cadr) |
| 1042 |
)) |
| 1043 |
(apply #'send-message self (class . super) :init args) |
| 1044 |
self) |
| 1045 |
) |
| 1046 |
;;; |
| 1047 |
(defmethod sunview-tty |
| 1048 |
(:input (buf &optional len) |
| 1049 |
(if (null len) (setq len (length (string buf)))) |
| 1050 |
(ttysw_input system-cadr buf len)) |
| 1051 |
(:output (buf &optional len) |
| 1052 |
(if (null len) (setq len (length (string buf)))) |
| 1053 |
(ttysw_output system-cadr buf len)) |
| 1054 |
(:flush () (send self :input "
")) |
| 1055 |
(:bell () (send self :output "^G" 1)) |
| 1056 |
;; tty |
| 1057 |
(:init (&optional par &rest args &key &allow-other-keys) |
| 1058 |
(when (null par) |
| 1059 |
(setq par (instantiate sunview-frame)) |
| 1060 |
(apply #'send (cons par (cons :init args)))) |
| 1061 |
(send self :parent par) |
| 1062 |
(setq system-cadr (window_create_tty (send par :cadr))) |
| 1063 |
(apply #'send-message self (class . super) :init args) |
| 1064 |
self) |
| 1065 |
) |
| 1066 |
|
| 1067 |
;;;; |
| 1068 |
(defmethod panel-item |
| 1069 |
(:row-offset () 0) |
| 1070 |
(:display-level (&optional v) nil) |
| 1071 |
(:font (&optional (f t)) |
| 1072 |
(cond |
| 1073 |
((numberp f) |
| 1074 |
(panel_set system-cadr win_font (setq font f))) |
| 1075 |
((stringp f) |
| 1076 |
(panel_set system-cadr win_font (setq font (pf_open f)))) |
| 1077 |
((eq f t)) |
| 1078 |
(t (setq font 0))) |
| 1079 |
font) |
| 1080 |
(:window_event (e) e) |
| 1081 |
(:menu-show (event) |
| 1082 |
(let ((k 0)) |
| 1083 |
(if (derivedp menu sunview-menu) |
| 1084 |
(setq k (menu_show (menu . system-cadr) |
| 1085 |
((send self :parent) . system-cadr) |
| 1086 |
event))) |
| 1087 |
(if (eq k 0) nil |
| 1088 |
(send menu :choice (1- k))))) |
| 1089 |
(:layout (&optional v) |
| 1090 |
(cond |
| 1091 |
(v (panel_set system-cadr panel_layout v)) |
| 1092 |
(t (panel_get system-cadr panel_layout)))) |
| 1093 |
(:horizontal (&optional (flag 0)) |
| 1094 |
(cond |
| 1095 |
((eq flag 0) |
| 1096 |
(equal (send self :layout) panel_horizontal)) |
| 1097 |
((null flag) |
| 1098 |
(send self :layout panel_vertical)) |
| 1099 |
(t (send self :layout panel_horizontal)))) |
| 1100 |
(:vertical (&optional (flag 0)) |
| 1101 |
(cond |
| 1102 |
((eq flag 0) |
| 1103 |
(equal (send self :layout) panel_vertical)) |
| 1104 |
((null flag) |
| 1105 |
(send self :layout panel_horizontal)) |
| 1106 |
(t (send self :layout panel_vertical)))) |
| 1107 |
(:enter-handler |
| 1108 |
;; method , function |
| 1109 |
(mouse-status method) |
| 1110 |
(when |
| 1111 |
method |
| 1112 |
(push (cons mouse-status method) event-handler-list) |
| 1113 |
(send self :set-eproc *item-event-function*)) |
| 1114 |
) |
| 1115 |
(:set-eproc (proc) |
| 1116 |
(panel_set |
| 1117 |
system-cadr panel_event_proc (send proc :pod-address))) |
| 1118 |
(:enter-notify-handler (method) |
| 1119 |
(cond |
| 1120 |
((null method)) |
| 1121 |
(t |
| 1122 |
(setq notify-handler method) |
| 1123 |
(send self :set-nproc *panel-notify-function*) |
| 1124 |
))) |
| 1125 |
(:set-nproc (proc) |
| 1126 |
(panel_set |
| 1127 |
system-cadr panel_notify_proc (send proc :pod-address))) |
| 1128 |
(:col (&optional (v col)) |
| 1129 |
(if v |
| 1130 |
(panel_set system-cadr panel_item_x |
| 1131 |
(xv_col (parent . system-cadr) (setq col v)))) |
| 1132 |
col) |
| 1133 |
(:row (&optional (v row)) |
| 1134 |
(if v (panel_set system-cadr panel_item_y |
| 1135 |
(xv_row (parent . system-cadr) (setq row v)))) |
| 1136 |
row) |
| 1137 |
(:item-col (&optional v) |
| 1138 |
(send self :col (* (parent . item-size) v)) |
| 1139 |
(round (/ col (parent . item-size)))) |
| 1140 |
(:item-row (&optional (v row)) |
| 1141 |
(send self :row v) |
| 1142 |
row) |
| 1143 |
(:set (&rest l) (panel_set system-cadr l)) |
| 1144 |
(:title |
| 1145 |
(&optional str) |
| 1146 |
(if str |
| 1147 |
(setq name |
| 1148 |
(let* ((len (length str)) |
| 1149 |
(s (make-string len))) |
| 1150 |
(dotimes (i len s) |
| 1151 |
(if (< i len) |
| 1152 |
(setf (aref s i) (aref str i)) |
| 1153 |
(setf (aref s i) #\ )))))) |
| 1154 |
(panel_set system-cadr panel_label_string name) |
| 1155 |
name) |
| 1156 |
(:show (&optional (flag t)) |
| 1157 |
(if flag (setq flag true) (setq flag null)) |
| 1158 |
(panel_set system-cadr panel_show flag) |
| 1159 |
) |
| 1160 |
(:notify-level |
| 1161 |
(&optional v) |
| 1162 |
(case |
| 1163 |
v |
| 1164 |
(all (setq v panel_all)) |
| 1165 |
(current (setq v panel_done)) |
| 1166 |
(none (setq v panel_none)) |
| 1167 |
(specified (setq v panel_specified)) |
| 1168 |
(non-printable (setq v panel_non_printable)) |
| 1169 |
) |
| 1170 |
(cond |
| 1171 |
((null v) |
| 1172 |
(setq v (panel_get system-cadr panel_notify_level)) |
| 1173 |
(cond |
| 1174 |
((equal v panel_all) 'all) |
| 1175 |
((equal v panel_none) 'none) |
| 1176 |
((equal v panel_done) 'done) |
| 1177 |
((equal v panel_specified) 'specified) |
| 1178 |
((equal v panel_non_printable) 'non-printable) |
| 1179 |
) |
| 1180 |
) |
| 1181 |
(t (panel_set system-cadr panel_notify_level v)))) |
| 1182 |
(:label-image (&optional image) |
| 1183 |
(if image |
| 1184 |
(panel_set panel_label_image image 0) |
| 1185 |
(panel_get system-cadr panel_label_image))) |
| 1186 |
;; panel-item |
| 1187 |
(:init (&rest l &key |
| 1188 |
title item-col item-row |
| 1189 |
vertical |
| 1190 |
horizontal |
| 1191 |
nproc notify-level |
| 1192 |
&allow-other-keys) |
| 1193 |
(if title (send self :title title)) |
| 1194 |
(send self :item-col (send parent :item-col item-col)) |
| 1195 |
(send self :item-row (send parent :item-row item-row)) |
| 1196 |
(send self :enter-notify-handler nproc) |
| 1197 |
(if notify-level (send self :notify-level notify-level)) |
| 1198 |
(if vertical (send self :vertical vertical)) |
| 1199 |
(if horizontal (send self :horizontal horizontal)) |
| 1200 |
(apply #'send-message self (class . super) :init l) |
| 1201 |
(send parent :push-item-object-list system-cadr self) |
| 1202 |
self) |
| 1203 |
) |
| 1204 |
;;; |
| 1205 |
;;; button |
| 1206 |
;;; |
| 1207 |
(defmethod panel-button-item |
| 1208 |
(:init (panel &rest args &key |
| 1209 |
((:title nam) "") |
| 1210 |
&allow-other-keys |
| 1211 |
) |
| 1212 |
(send self :parent panel) |
| 1213 |
(setq name nam) |
| 1214 |
(setq system-cadr |
| 1215 |
(panel_create_button (panel . system-cadr))) |
| 1216 |
(apply #'send-message self (class . super) :init args) |
| 1217 |
self) |
| 1218 |
) |
| 1219 |
;;; |
| 1220 |
(defmethod panel-text-item |
| 1221 |
(:row-offset () (if (send parent :vertical) 1 0)) |
| 1222 |
(:length (&optional v) |
| 1223 |
(if v |
| 1224 |
(panel_set system-cadr panel_value_display_length v) |
| 1225 |
(panel_get system-cadr panel_value_display_length))) |
| 1226 |
(:value (&optional v) |
| 1227 |
(if v |
| 1228 |
(panel_set system-cadr panel_value (string v))) |
| 1229 |
(adr_to_string (panel_get system-cadr panel_value))) |
| 1230 |
(:init (panel &rest args &key |
| 1231 |
((:title nam) "") |
| 1232 |
length |
| 1233 |
value |
| 1234 |
&allow-other-keys |
| 1235 |
) |
| 1236 |
(send self :parent panel) (setq name nam) |
| 1237 |
(setq system-cadr |
| 1238 |
(panel_create_text (panel . system-cadr))) |
| 1239 |
(apply #'send-message self (class . super) :init args) |
| 1240 |
(if value (send self :value value)) |
| 1241 |
(if length (send self :length length) |
| 1242 |
(send self :length (send panel :item-size))) |
| 1243 |
self) |
| 1244 |
) |
| 1245 |
|
| 1246 |
;;; |
| 1247 |
;;; choice , cycle , toggle |
| 1248 |
;;; |
| 1249 |
(defmethod panel-selectable-item |
| 1250 |
(:row-offset () |
| 1251 |
(cond |
| 1252 |
((send self :vertical) |
| 1253 |
(case |
| 1254 |
(send self :display-level) |
| 1255 |
(none 0) |
| 1256 |
(current 1) |
| 1257 |
(t (1+ (length choices))))) |
| 1258 |
(t 0))) |
| 1259 |
(:strings (&optional (v -1)) |
| 1260 |
(cond |
| 1261 |
((null v) |
| 1262 |
(if strings |
| 1263 |
strings |
| 1264 |
(setq strings |
| 1265 |
(mapcar #'string (coerce choices cons)))) |
| 1266 |
(if strings (panel_set system-cadr panel_choice_strings strings 0))) |
| 1267 |
((eq v -1) strings) |
| 1268 |
(t |
| 1269 |
(setq strings (mapcar #'string (coerce v cons))) |
| 1270 |
(if strings (panel_set system-cadr panel_choice_strings strings 0)))) |
| 1271 |
strings) |
| 1272 |
(:display-level (&optional v) |
| 1273 |
(case v |
| 1274 |
(all (setq v panel_all)) |
| 1275 |
(current (setq v panel_current)) |
| 1276 |
(none (setq v panel_none))) |
| 1277 |
(cond |
| 1278 |
((null v) |
| 1279 |
(setq v (panel_get system-cadr panel_display_level)) |
| 1280 |
(cond |
| 1281 |
((equal v panel_all) 'all) |
| 1282 |
((equal v panel_none) 'none) |
| 1283 |
((equal v panel_current) 'current))) |
| 1284 |
(t (panel_set system-cadr panel_display_level v)))) |
| 1285 |
(:choices (&optional vec) |
| 1286 |
(if vec (setq choices (coerce vec vector))) |
| 1287 |
choices) |
| 1288 |
(:value (&optional v) |
| 1289 |
(send self :choice (position v choices))) |
| 1290 |
(:choice (&optional k) |
| 1291 |
(cond |
| 1292 |
((and (numberp k) (< -1 k (length choices))) |
| 1293 |
(panel_set system-cadr panel_value k) (aref choices k)) |
| 1294 |
(t (aref choices (panel_get system-cadr panel_value))))) |
| 1295 |
;;; Panel-selectable-item |
| 1296 |
(:init (&rest args &key |
| 1297 |
((:title nam) "") |
| 1298 |
((:choices c) #("")) |
| 1299 |
((:strings strs)) |
| 1300 |
(display-level 'all) |
| 1301 |
(value nil) |
| 1302 |
&allow-other-keys) |
| 1303 |
(setq choices (coerce c vector)) |
| 1304 |
(if (null strs) (setq strings (mapcar #'string choices))) |
| 1305 |
(apply #'send-message self (class . super) :init args) |
| 1306 |
(send self :display-level display-level) |
| 1307 |
(if value (send self :value value)) |
| 1308 |
(send self :strings strs) |
| 1309 |
self) |
| 1310 |
) |
| 1311 |
;;; |
| 1312 |
(defmethod panel-choice-item |
| 1313 |
(:init (panel &rest args &key |
| 1314 |
((:title nam) "") |
| 1315 |
(display-level 'all) |
| 1316 |
&allow-other-keys) |
| 1317 |
(send self :parent panel) (setq name nam) |
| 1318 |
(setq system-cadr (panel_create_choice (panel . system-cadr))) |
| 1319 |
(apply #'send-message self (class . super) :init args) |
| 1320 |
self) |
| 1321 |
) |
| 1322 |
;;; |
| 1323 |
(defmethod panel-cycle-item |
| 1324 |
(:init (panel &rest args &key |
| 1325 |
((:title nam) "") |
| 1326 |
(display-level 'current) |
| 1327 |
&allow-other-keys) |
| 1328 |
(send self :parent panel) (setq name nam) |
| 1329 |
(setq system-cadr |
| 1330 |
(panel_create_cycle (panel . system-cadr))) |
| 1331 |
(apply #'send-message self (class . super) :init args) |
| 1332 |
self) |
| 1333 |
) |
| 1334 |
|
| 1335 |
;;; |
| 1336 |
(defmethod panel-toggle-item |
| 1337 |
(:value (&optional (v 0)) |
| 1338 |
(if (eq v t) (setq v choices)) |
| 1339 |
(cond |
| 1340 |
((eq v 0) (send self :choice)) |
| 1341 |
(t (let ((ws 0)) |
| 1342 |
(mapc #'(lambda (x) |
| 1343 |
(if (setq x (position x choices)) |
| 1344 |
(setq ws (logior (ash 1 x) ws)))) |
| 1345 |
(coerce v cons)) |
| 1346 |
(send self :choice ws))))) |
| 1347 |
(:choice (&optional (k (panel_get system-cadr panel_value))) |
| 1348 |
(let (ws) |
| 1349 |
(panel_set system-cadr panel_value k) |
| 1350 |
(dotimes (i (length choices) (reverse ws)) |
| 1351 |
(if (eq 1 (logand 1 k)) |
| 1352 |
(setq ws (cons (aref choices i) ws))) |
| 1353 |
(setq k (ash k -1))) |
| 1354 |
)) |
| 1355 |
(:init (panel &rest args &key |
| 1356 |
((:title nam) "") |
| 1357 |
&allow-other-keys) |
| 1358 |
(send self :parent panel) (setq name nam) |
| 1359 |
(setq system-cadr |
| 1360 |
(panel_create_toggle (panel . system-cadr))) |
| 1361 |
(apply #'send-message self (class . super) :init args) |
| 1362 |
self) |
| 1363 |
) |
| 1364 |
;;; |
| 1365 |
;;; slider |
| 1366 |
;;; |
| 1367 |
(defmethod panel-slider-item |
| 1368 |
(:value (&optional v) |
| 1369 |
(if v (panel_set system-cadr panel_value v) |
| 1370 |
(panel_get system-cadr panel_value))) |
| 1371 |
(:min (&optional v) |
| 1372 |
(if v (panel_set system-cadr panel_min_value v) |
| 1373 |
(panel_get system-cadr panel_min_value))) |
| 1374 |
(:max (&optional v) |
| 1375 |
(if v (panel_set system-cadr panel_max_value v) |
| 1376 |
(panel_get system-cadr panel_max_value))) |
| 1377 |
(:row-offset () (if (send self :vertical) 1 0)) |
| 1378 |
(:length (&optional v) |
| 1379 |
(if v |
| 1380 |
(panel_set system-cadr panel_slider_width v) |
| 1381 |
(panel_get system-cadr panel_slider_width))) |
| 1382 |
(:init (panel &rest l &key |
| 1383 |
((:title nam) "") |
| 1384 |
((:length len) 100) |
| 1385 |
((:min min-v) 0) |
| 1386 |
value |
| 1387 |
((:max max-v) 100) |
| 1388 |
&allow-other-keys) |
| 1389 |
(send self :parent panel) (setq name nam) |
| 1390 |
(setq system-cadr |
| 1391 |
(panel_create_slider |
| 1392 |
(panel . system-cadr) |
| 1393 |
panel_show_value true |
| 1394 |
panel_min_value min-v |
| 1395 |
panel_max_value max-v)) |
| 1396 |
(apply #'send-message self (class . super) :init l) |
| 1397 |
(send self :value value) |
| 1398 |
(send self :length len) |
| 1399 |
self) |
| 1400 |
) |
| 1401 |
;;; |
| 1402 |
;;; message |
| 1403 |
;;; |
| 1404 |
(defmethod panel-message-item |
| 1405 |
(:init (panel &rest args &key |
| 1406 |
((:title nam) "") |
| 1407 |
&allow-other-keys |
| 1408 |
) |
| 1409 |
(send self :parent panel) (setq name nam) |
| 1410 |
(setq system-cadr |
| 1411 |
(panel_create_message (panel . system-cadr))) |
| 1412 |
(apply #'send-message self (class . super) :init args) |
| 1413 |
self) |
| 1414 |
) |
| 1415 |
;;; |
| 1416 |
;;; Menu |
| 1417 |
;;; |
| 1418 |
(defmethod sunview-menu |
| 1419 |
(:choice (k) (elt choices k)) |
| 1420 |
(:strings |
| 1421 |
(&optional v) |
| 1422 |
(setq strings (mapcar #'string (coerce v cons))) |
| 1423 |
(menu_set system-cadr menu_strings strings 0) |
| 1424 |
) |
| 1425 |
(:ncols (&optional v) |
| 1426 |
(if v (menu_set system-cadr menu_ncols v) |
| 1427 |
(menu_get system-cadr menu_ncols))) |
| 1428 |
(:nrows (&optional v) |
| 1429 |
(if v (menu_set system-cadr menu_nrows v) |
| 1430 |
(menu_get system-cadr menu_nrows))) |
| 1431 |
;;; (:boxed (&optional v) |
| 1432 |
;;; (not (zerop |
| 1433 |
;;; (if v (menu_set system-cadr menu_boxed v) |
| 1434 |
;;; (menu_get system-cadr menu_boxed))))) |
| 1435 |
(:find (str) |
| 1436 |
(menu_find system-cadr menu_string (string str))) |
| 1437 |
(:set (&rest l) (menu_set l)) |
| 1438 |
(:insert (nth v) |
| 1439 |
(menu_set system-cadr menu_insert nth v)) |
| 1440 |
(:string-item (str i) |
| 1441 |
(menu_set system-cadr menu_string_item |
| 1442 |
(string str) i)) |
| 1443 |
(:init (&rest args &key |
| 1444 |
frame |
| 1445 |
((:strings strs)) |
| 1446 |
((:choices cs)) |
| 1447 |
ncols nrows |
| 1448 |
&allow-other-keys) |
| 1449 |
(setq choices cs) |
| 1450 |
(cond |
| 1451 |
(strs (setq strings (mapcar #'string (coerce strs cons))) |
| 1452 |
(if (null cs) (setq choices (coerce strs cons)))) |
| 1453 |
(t (setq strings (mapcar #'string (coerce choices cons))))) |
| 1454 |
(cond |
| 1455 |
(frame |
| 1456 |
(setq system-cadr (window_get (frame . system-cadr) |
| 1457 |
win_menu))) |
| 1458 |
(t (setq system-cadr (menu_create menu_strings strings 0)))) |
| 1459 |
(apply #'send-message self (class . super) :init args) |
| 1460 |
(if ncols (send self :ncols ncols)) |
| 1461 |
(if nrows (send self :nrows nrows)) |
| 1462 |
self) |
| 1463 |
) |
| 1464 |
;;; |
| 1465 |
#| |
| 1466 |
(defclass menu-item |
| 1467 |
:super sunview-object |
| 1468 |
:slots (name)) |
| 1469 |
|
| 1470 |
(defmethod menu-item |
| 1471 |
(:set-eproc (proc) |
| 1472 |
(menu_set |
| 1473 |
system-cadr menu_gen_proc (send proc :pod-address))) |
| 1474 |
(:set (&rest l) (menu_set l)) |
| 1475 |
(:insert (nth v) |
| 1476 |
(menu_item_set system-cadr menu_insert nth v)) |
| 1477 |
(:init (&rest args &key |
| 1478 |
((:name nam) "") |
| 1479 |
cadr |
| 1480 |
&allow-other-keys) |
| 1481 |
(setq name nam) |
| 1482 |
(if cadr |
| 1483 |
(setq system-cadr cadr) |
| 1484 |
(setq system-cadr (menu_create_item MENU_STRING name))) |
| 1485 |
(apply #'send-message self (class . super) :init args) |
| 1486 |
self) |
| 1487 |
) |
| 1488 |
|# |
| 1489 |
|
| 1490 |
(sunview-set-get-method sunview-window x) |
| 1491 |
(sunview-set-get-method sunview-window y) |
| 1492 |
(sunview-set-get-method sunview-window width) |
| 1493 |
(sunview-set-get-method sunview-window height) |
| 1494 |
(sunview-set-get-method sunview-window columns) |
| 1495 |
(sunview-set-get-method sunview-window cursor) |
| 1496 |
|
| 1497 |
(sunview-set-get-method sunview-window column_width) |
| 1498 |
(sunview-set-get-method sunview-window column_gap) |
| 1499 |
(sunview-set-get-method sunview-window row_height) |
| 1500 |
(sunview-set-get-method sunview-window row_gap) |
| 1501 |
(sunview-set-get-method sunview-window top_margin) |
| 1502 |
(sunview-set-get-method sunview-window bottom_margin) |
| 1503 |
(sunview-set-get-method sunview-window left_margin) |
| 1504 |
(sunview-set-get-method sunview-window right_margin) |
| 1505 |
;;;; |
| 1506 |
(defmethod canvas-viewsurface |
| 1507 |
(:canvas (&rest args) |
| 1508 |
(if args |
| 1509 |
(apply #'send (cons canvas args)) |
| 1510 |
canvas)) |
| 1511 |
(:frame (&rest args) |
| 1512 |
(if args |
| 1513 |
(apply #'send (cons frame args)) |
| 1514 |
frame)) |
| 1515 |
(:pixwin () pixwindow) |
| 1516 |
(:color (&optional v) (if v (setq color v) color)) |
| 1517 |
(:init (&key |
| 1518 |
((:canvas c) nil) |
| 1519 |
(parent null) |
| 1520 |
(size 300) |
| 1521 |
(width size) |
| 1522 |
(height size) |
| 1523 |
(cmap-type :mono) |
| 1524 |
(x 0) (y 0) |
| 1525 |
(title " ") |
| 1526 |
((:buffer-mode bm) nil) |
| 1527 |
&allow-other-keys ) |
| 1528 |
(setq buffer-mode bm) |
| 1529 |
(cond |
| 1530 |
((numberp c) |
| 1531 |
(setq frame (instantiate sunview-frame)) |
| 1532 |
(setq (frame . system-cadr) (window_get c win_owner)) |
| 1533 |
(setq canvas (instantiate sunview-canvas)) |
| 1534 |
(setq (canvas . system-cadr) c) |
| 1535 |
(send canvas :parent frame)) |
| 1536 |
((derivedp c sunview-canvas) |
| 1537 |
(setq frame (c . parent) canvas c)) |
| 1538 |
(t |
| 1539 |
(setq frame (instance sunview-frame :init nil :x x :y y |
| 1540 |
:title title)) |
| 1541 |
(setq canvas (instance sunview-canvas :init frame |
| 1542 |
:width width :height height)) |
| 1543 |
(send frame :show) |
| 1544 |
)) |
| 1545 |
(send canvas :cmsname (format nil "viewsurface~s" (unix:getpid))) |
| 1546 |
; (send self :set-cmap-type cmap-type) |
| 1547 |
(setq pixwindow (send canvas :pixwin)) |
| 1548 |
(setq rasterop pix_src color 255) |
| 1549 |
(setq back-pixwindow pixwindow) |
| 1550 |
self) |
| 1551 |
(:rasterop (&optional v) |
| 1552 |
(if v (setq rasterop v) rasterop)) |
| 1553 |
(:close () (send frame :destroy)) |
| 1554 |
(:set-erase-mode () |
| 1555 |
(setq rasterop pix_clr) |
| 1556 |
) |
| 1557 |
(:set-show-mode () (setq rasterop pix_src)) |
| 1558 |
(:buffer-mode (&optional (v buffer-mode)) (setq buffer-mode v)) |
| 1559 |
(:clear |
| 1560 |
() |
| 1561 |
(let ((width (send self :width)) (height (send self :height)) |
| 1562 |
(pixwin (if buffer-mode back-pixwindow pixwindow))) |
| 1563 |
(pw_writebackground pixwindow 0 0 width height pix_clr) |
| 1564 |
;;; (pr_rop pixwin 0 0 width height pix_src 0 0 0) |
| 1565 |
)) |
| 1566 |
;;(pw_writebackground pixwindow 0 0 width height pix_clr) |
| 1567 |
;;(pw_write (canvas_pixwin canvas) 0 0 width height pix_src 0 0 0) |
| 1568 |
(:flush |
| 1569 |
() |
| 1570 |
(when buffer-mode |
| 1571 |
(pw_rop pixwindow 0 0 (send self :width) (send self :height) |
| 1572 |
pix_src back-pixwindow 0 0) |
| 1573 |
(pw_batch_off pixwindow) |
| 1574 |
) |
| 1575 |
t) |
| 1576 |
(:drawline-primitive |
| 1577 |
(x0 y0 x1 y1 &optional (c color)) ;; x0 y0 x1 y1 |
| 1578 |
(if (null c) (setq c color)) |
| 1579 |
(if buffer-mode |
| 1580 |
(pr_vector back-pixwindow x0 y0 x1 y1 rasterop c) |
| 1581 |
(pw_vector pixwindow x0 y0 x1 y1 rasterop c))) |
| 1582 |
(:draw-line (p1 p2 &optional color) |
| 1583 |
(send self :drawline-primitive |
| 1584 |
(round (aref p1 0)) (round (aref p1 1)) |
| 1585 |
(round (aref p2 0)) (round (aref p2 1)) color)) |
| 1586 |
(:drawtext-primitive |
| 1587 |
(textstring x0 y0 &key (font 0) (op rasterop) |
| 1588 |
(pixwin (if buffer-mode back-pixwindow pixwindow))) |
| 1589 |
(pr_text pixwin x0 y0 rasterop font |
| 1590 |
(string-body-address textstring))) |
| 1591 |
(:drawpolygon-primitive |
| 1592 |
(points &key (op pix_set) |
| 1593 |
(x 0) (y 0) |
| 1594 |
(pixwin (if buffer-mode back-pixwindow pixwindow)) |
| 1595 |
(rect 0) (sx 0) (sy 0)) |
| 1596 |
(pw_polygon_2 pixwin x y 1 (vector (length points)) |
| 1597 |
points op rect sx sy)) |
| 1598 |
(:drawpolyline-primitive |
| 1599 |
(points &key (op pix_set) |
| 1600 |
(pixwin (if buffer-mode back-pixwindow pixwindow)) |
| 1601 |
(x 0) (y 0) |
| 1602 |
(mvlist 0) (brush 0) (texture 0)) |
| 1603 |
(pw_polyline pixwin x y |
| 1604 |
(length points) points mvlist brush texture op)) |
| 1605 |
) |
| 1606 |
|
| 1607 |
(defun geometry::default-viewsurface (&rest args) |
| 1608 |
(send-lexpr (instantiate canvas-viewsurface) :init |
| 1609 |
args)) |