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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
|
;;;
;;; hello-world ; show text and lines on canvas
;;; icon-disp ; show hellow_world.icon
;;; byebye-world ; show quit-button
;;; icon-browser1 ; show listing and selection
;;; icon-browser2 ; show image and name of icons
;;; show-event ; show event name
;;; M.I. 1989.5.27
(defun demo nil
(hello-world) (icon-disp) (byebye-world)
(icon-browser1) (icon-browser2) (show-event))
(defun hello-world nil
(setq *frame* (window_create_frame 0 frame_label "Hello world."))
(setq *canvas* (window_create_canvas *frame* win_width 300 win_height 300 0))
(setq *pixwin* (canvas_pixwin *canvas*))
(pw_vector *pixwin* 100 100 200 100 PIX_SRC 1)
(pw_vector *pixwin* 100 200 200 200 PIX_SRC 1)
(pw_vector *pixwin* 100 100 100 200 PIX_SRC 1)
(pw_vector *pixwin* 200 100 200 200 PIX_SRC 1)
(pw_text *pixwin* 125 150 PIX_SRC 0 "Hello World!")
(window_fit *canvas*)
(window_fit *frame*)
(window_set *frame* win_show 1 0)
)
(defun icon-disp nil
(notify_do_dispatch)
(setq hpixrect (icon_load_image
"/usr/include/images/hello_world.icon"))
(setq hicon (icon_create icon_image hpixrect 0))
(setq *frame* (window_create_frame 0 frame_label "ICON"))
(setq *canvas* (window_create_canvas *frame*
win_height 64
win_width 64
0))
(setq *pixwin* (canvas_pixwin *canvas*))
(pw_rop *pixwin* 0 0 64 64 pix_src hpixrect 0 0)
(window_fit *frame*)
(window_set *frame* win_show 1 0)
)
(defun-c-callable quit-proc
((p :integer) (e :integer)) :integer
(format t "in quit-proc *frame* = ~S~%" *frame*)
(window_destroy *frame*)
(setq *quit* t))
(defun byebye-world nil
(setq bold (pf_open "/usr/lib/fonts/fixedwidthfonts/screen.b.12"))
(if (= bold 0) (return-from simple nil))
; (setq hello (read-icon "/usr/include/images/hello_world.icon"))
; (setq hpixrect (mem_point 64 64 1 hello))
(setq hpixrect (icon_load_mpr "/usr/include/images/hello_world.icon"
"no file"))
(setq hicon (icon_create icon_image hpixrect 0))
(setq *frame* (window_create_frame 0 frame_label "byebye-world"
frame_icon hicon
0))
(setq *panel* (window_create_panel *frame* win_font bold 0))
(panel_create_message *panel*
panel_label_string "Hit button to quit."
0)
(panel_create_button *panel*
panel_label_image
(panel_button_image *panel* "byebye" 5 0)
panel_notify_proc
(pod-address 'quit-proc)
0)
(window_fit *panel*)
(window_fit *frame*)
(window_set *frame* win_show 1 0)
)
(defun-c-callable ls-proc
((p :integer) (e :integer)) :integer
(setq str (concatenate string "ls "
(adr_to_string
(panel_get dir_item panel_value))
"^J"))
(ttysw_input *tty* str (length str))
)
(defun-c-callable SHOW-PROC
((p :integer) (e :integer)) :integer
(panel_set image_item
panel_item_x (attr_col 5)
panel_item_y (attr_row 4)
panel_label_image
(icon_load_image
(concatenate string
(adr_to_string (panel_get_value dir_item))
"/"
(get_selection))
)
0)
)
(defun icon-browser1 nil
(notify_do_dispatch)
(setq *frame* (window_create_frame 0 frame_label "icon_browser1" 0))
(setq *tty* (window_create_tty *frame* win_columns 80
win_rows 20
0))
(setq control_panel (window_create_panel *frame* 0))
(setq dir_item (panel_create_text
control_panel
panel_value_display_length 13
panel_label_string "Dir: "
panel_value (unix:getwd)
0))
(setq fname_item (panel_create_text
control_panel
panel_item_x (attr_col 0)
panel_item_y (attr_row 1)
panel_value_display_length 13
panel_label_string "File:"
0))
(panel_create_button control_panel
panel_item_x (attr_col 0)
panel_item_y (attr_row 2)
panel_label_image (panel_button_image
control_panel "List" 0 0)
panel_notify_proc (pod-address 'ls-proc)
0)
(panel_create_button control_panel
panel_label_image (panel_button_image
control_panel "Show" 0 0)
panel_notify_proc (pod-address 'show-proc)
0)
(panel_create_button control_panel
panel_label_image (panel_button_image
control_panel "Quit" 0 0)
panel_notify_proc (pod-address 'quit-proc)
0)
(window_fit control_panel)
(window_fit *frame*)
(setq display_panel (window_create_panel *frame*
win_below control_panel
win_right_of *tty*
0))
(setq image_item (panel_create_message display_panel 0))
(window_set *frame* win_show 1 0)
)
(defun icon_load_image (fname)
; (mem_point 64 64 8
; (read-face fname)))
; (mem_point 64 64 1
; (read-icon fname))
(icon_load_mpr fname (make-string 100))
)
(setq image_count 0)
(setq previous_image_count 0)
(defun-c-callable BROWSE-PROC
((a :integer) (b :integer)) :integer
(setq current_dir (adr_to_string (panel_get_value dir_item)))
(setq name_list (expand_name
(concatenate
string
current_dir "/"
(adr_to_string (panel_get fname_item panel_value)))))
(setq file_count (length name_list))
(do ((ip (panel_get display_panel panel_first_item)
(panel_get ip panel_next_item)))
((zerop ip))
(pr_destroy (panel_get ip panel_label_image))
(panel_free ip))
(setq previous_image_count image_count)
(setq image_count 0)
(dotimes
(row file_count)
(when
(not (zerop
(setq image
(icon_load_image
(svref name_list image_count)))))
(panel_create_message display_panel
panel_item_y (attr_row (* 2 row))
panel_item_x (attr_col 0)
panel_label_image image
0)
(panel_create_message display_panel
panel_item_y (attr_row (1+ (* 2 row)))
panel_item_x (attr_col 0)
panel_label_image
(panel_button_image
display_panel
(svref name_list image_count) 0 0)
0)
)
(inc image_count)
)
(if (<= image_count previous_image_count)
(panel_update_scrolling_size display_panel))
(panel_paint display_panel panel_clear)
)
(defun icon-browser2 nil
(notify_do_dispatch)
(setq *frame* (window_create_frame 0 frame_label "icon_browser_2" 0))
(init_control_panel 'browse-proc)
(init_display_panel)
(window_set control_panel
win_width (window_get display_panel win_width)
0)
(window_fit *frame*)
(window_set *frame* win_show 1 0)
)
(defun init_control_panel (proc)
(setq control_panel (window_create_panel *frame* 0))
(setq dir_item (panel_create_text
control_panel
panel_label_x (attr_col 0)
panel_label_y (attr_row 0)
panel_value_display_length 23
;; panel_value (unix:getwd)
panel_value "/usr/include/images"
panel_label_string "Dir: "
0))
(panel_create_button control_panel
panel_label_image
(panel_button_image control_panel "Browse" 0 0)
panel_notify_proc (pod-address proc)
0)
(setq fname_item (panel_create_text
control_panel
panel_item_x (attr_col 0)
panel_item_y (attr_row 1)
panel_value_display_length 23
panel_value "*"
panel_label_string "File:"
0))
(panel_create_button control_panel
panel_label_image (panel_button_image
control_panel "Quit" 6 0)
panel_notify_proc (pod-address 'quit-proc)
0)
(window_fit_height control_panel)
(window_set control_panel panel_caret_item fname_item 0)
)
(defun init_display_panel nil
(setq sb (scrollbar_create scroll_margin 10 0))
;; (setq width (scrollbar_get sb scroll_thickness))
(setq width 8)
(setq display_panel
(window_create_panel *frame*
win_below control_panel
win_x 0
win_vertical_scrollbar sb
0))
(window_set display_panel
win_row_height 100
win_column_width 100
win_row_gap 10
win_column_gap 10
0)
(window_set display_panel
win_left_margin (+ width 10)
win_top_margin 10
win_rows 4
win_columns 4
0)
(window_set display_panel win_left_margin 10 0)
)
(defun show-msg (window-cadr event msg)
(cond
((equal window-cadr *canvas*)
(let ((we (canvas_window_event *canvas* event)))
(pw_text (canvas_pixwin *canvas*) 50 120 pix_src 0
(format nil "time:~a " (event_time we)))
(setq last-time (event_time we))
(pw_text (canvas_pixwin *canvas*) 50 140 pix_src 0
(setq msg (format nil "c:~a at ~s ~s~a " msg
(event_x we) (event_y we)
(if
(event_is_button event)
(cond
((event_is_up we) " up.")
((event_is_down we) " down.")
(t "."))
"."))))
))
((equal window-cadr *panel*)
(let ((we (panel_window_event *panel* event)))
(pw_text (canvas_pixwin *canvas*) 50 160 pix_src 0
(format nil "p:~a at ~s ~s,~s. " msg
(event_x we) (event_y we)
(when
(event_is_button we)
(cond
((event_is_up we) 'up)
((event_is_down we) 'down)
(t "")))))))
((equal window-cadr *frame*)
(pw_text (canvas_pixwin *canvas*) 50 180 pix_src 0
(format nil "~a on frame. " msg)))
))
(defun-c-callable eventer-window-handler (window-cadr event)
(let ((id (event_id event)))
(cond
((equal id loc_drag) (show-msg window-cadr event "dragging"))
((equal id loc_move) (show-msg window-cadr event "moving"))
((equal id loc_still) (show-msg window-cadr event "still"))
((equal id ms_left) (show-msg window-cadr event "left"))
((equal id ms_right) (show-msg window-cadr event "right"))
((equal id ms_middle) (show-msg window-cadr event "middle"))
((equal id loc_winenter) (show-msg window-cadr event "winenter"))
((equal id loc_winexit) (show-msg window-cadr event "winexit"))
((equal id loc_rgnenter) (show-msg window-cadr event "rgnenter"))
((equal id loc_rgnexit) (show-msg window-cadr event "rgnexit"))
)
))
(defun show-event nil
(notify_do_dispatch)
(setq count 0)
(setq *Frame*
(window_create_frame
null frame_label "Show event" win_x 700 win_y 30
win_event_proc (pod-address 'eventer-window-handler)
frame_icon
(icon_create icon_image
(icon_load_mpr
"/usr/include/images/hello_world.icon"
(setq errbuf (make-string 32))))))
(setq *panel*
(window_create_panel
*Frame*
win_event_proc (pod-address 'eventer-window-handler)
win_font
(pf_open "/usr/lib/fonts/fixedwidthfonts/screen.b.12")))
(panel_create_message
*panel* panel_label_string "Hit button to quit.")
(panel_create_button
*panel* panel_label_image (panel_button_image *panel* "quit" 5)
panel_notify_proc (pod-address 'quit-proc))
(window_fit *panel*)
(setq *canvas*
(window_create_canvas
*Frame* win_width 300 win_height 200
win_x 0 win_below *panel*
win_ignore_pick_event loc_still
win_consume_pick_event loc_drag
win_consume_pick_event win_in_transit_events
win_consume_pick_event win_mouse_buttons
win_event_proc (pod-address 'eventer-window-handler)))
(setq *pixwin* (canvas_pixwin *canvas*))
(pw_polygon_2 *pixwin* 0 0 1 #(3) #(10 10 100 10 50 50) pix_set 0 0 0)
(pw_polyline *pixwin* 0 0 3
(list #f(50 10) #f(150 10) #f(100 50)) 0 0 0 pix_set)
(pw_polypoint *pixwin* 0 0 3 '(10 20 200 20 150 50) pix_set)
(window_fit *Frame*)
(window_set *Frame* win_show true)
)
|