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
|
;;;;
;;;; Xwindow panel
;;;;
;;;; Copyright(c) Toshihiro MATSUI, ETL, 1993
;;;;
(in-package "X")
(require :xdecl "Xdecl.l")
(eval-when (compile eval) (require :Xtop "Xtop"))
(export '())
;;;;;;;;;;;;;;;;;;;;
;; P A N E L
;;;;;;;;;;;;;;;;;;;;
(defmethod panel
(:create (&rest args
&key ((:item-height iheight) 28)
((:item-width iwidth) 50)
(font font-lucidasans-bold-12)
((:background color))
(parent)
(event-mask nil)
&allow-other-keys)
(unless color
(setq color
(if parent (send self :background) *bisque1*)))
(send-super* :create :border-width 1 :background color
:parent parent
:event-mask event-mask args)
(setq fontid (if (numberp font) font (font-id font)))
(send gcon :font fontid)
(setf item-width iwidth
item-height iheight)
(setq rows (/ (send self :height) item-height)
columns (/ (send self :width) item-width))
(setq items nil
next-x 0
next-y 0)
(setf light-edge-color (get-lighter-pixel bg-color 1.4 (send self :colormap))
dark-edge-color (get-lighter-pixel bg-color 0.6 (send self :colormap))
topleft-edge-polygon
(make-topleft-edge-polygon 0 0 width height 2) )
(send self :flush)
self)
(:expose (event)
(send self :redraw)
;(send-all subwindows :expose event)
)
(:redraw () )
(:resize (w h)
(send-super :resize w h)
(setq topleft-edge-polygon
(make-topleft-edge-polygon 0 0 w h 2) )
self)
(:items () items)
(:locate-item (item &optional x y)
(let ((width-left (- (send self :width) next-x 10)))
(send self :associate item)
(when (< width-left (send item :width))
(setq next-x 0)
(setq next-y
(max (+ next-y item-height)
(apply #'max 0
(mapcar
#'(lambda (item) (+ (send item :height)
(send item :y)))
items)))) )
;; when :x/:y is not given, provide default item position
(unless x (setq x (+ next-x 5)))
(unless y (setq y (+ next-y 5)))
(send item :move x y)
(setq next-x (+ next-x (max item-width (+ (send item :width) 5)))
next-y (- (send item :y) 5))
(send item :map)
(push item items)
item) )
(:create-item (klass label receiver method
&rest args
&key (x) (y) (font fontid)
&allow-other-keys)
(send self :locate-item
(instance* klass :create label receiver method
:font font
:parent self
:map nil
args)
x y) )
(:create-menubar ( &rest args
&key (x 0) (y 0) (font fontid)
&allow-other-keys)
(let (menubar)
(setq menubar (instance* menubar-panel :create
:font font
:parent self
:map nil
args))
(setq next-y (send menubar :height))
(send self :locate-item menubar x y)
)
)
(:active-menu (w)
(if (and active-menu (not (eql w active-menu)))
(send active-menu :unmap-menu))
(setq active-menu w)
(send active-menu :popup-menu))
(:delete-items ()
(setq next-x 0 next-y 0)
(send-all items :destroy)
(setq items nil))
)
;; notifiers
;; applications can override following methods
;; but what should happen when a button is pressed inside the panel?
(defmethod panel
(:quit (&rest a) (throw :window-main-loop nil))
(:KeyEnter (pos) nil)
; (:KeyRelease (pos) nil)
(:ButtonPress (pos) nil)
(:ButtonRelease (pos) nil)
(:MotionNotify (pos) nil)
(:EnterNotify (event)
;; (if drawable (setinputfocus *display* drawable 1 0))
;; BadMatch error occurs when the window is unmapped
)
(:LeaveNotify (pos) nil))
;;;;;;;;;;;;;;;;;;;;
;; MenuBar
;;;;;;;;;;;;;;;;;;;;
(defmethod menubar-panel
(:create (&rest args
&key (font font-lucidasans-bold-12)
width height
&allow-other-keys)
(let* (xsize ysize labeldots)
(setf labeldots (textdots "x" font))
(setq xsize
(if (null width) 60 width))
(setq ysize
(if height
height
(+ (aref labeldots 0) (aref labeldots 1) 6)))
(send-super* :create :width xsize :height ysize :border-width 0 args)
(send self :3d-fill-rectangle 0 0 width height 2
light-edge-color dark-edge-color bg-color
topleft-edge-polygon)
(setq next-x 3 next-y 2)
(send self :flush)
self)
)
(:locate-item (item &optional x y)
(let ((width-left (- (send self :width) next-x 10)))
(when (< width-left (send item :width))
(setq next-x 3)
(setq next-y (+ next-y item-height)))
;; when :x/:y is not given, provide default item position
(send item :move next-x next-y )
(setq next-x (+ (send item :x) (send item :width))
next-y (send item :y) )
(send item :map)
(push item items)
item) )
(:popup-all-menus () (send-all items :popup-menu))
(:unmap-all-menus () (send-all items :unmap-menu))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide :xpanel "@(#)$Id: Xpanel.l,v 1.1.1.1 2003/11/20 07:46:35 eus Exp $")
|