5 (define-g-boxed-cstruct selection-data "GtkSelectionData"
6 (selection gdk-atom-as-string :initform nil)
7 (target gdk-atom-as-string :initform nil)
8 (type gdk-atom-as-string :initform nil)
9 (format :int :initform 0)
10 (data :pointer :initform (null-pointer))
11 (length :int :initform 0)
12 (display (g-object display) :initform nil))
14 (export (boxed-related-symbols 'selection-data))
16 (defun widget-flags (widget)
17 (convert-from-foreign (gtk-object-flags-as-integer widget) 'widget-flags))
19 (defun (setf widget-flags) (new-value widget)
20 (setf (gtk-object-flags-as-integer widget)
21 (convert-to-foreign new-value 'widget-flags))
24 (export 'widget-flags)
26 (defcstruct %gtk-widget
28 (:private-flags :uint16)
31 (:name (:pointer :char))
33 (:requisition requisition-cstruct)
34 (:allocation allocation-cstruct)
38 (defun widget-state (widget)
39 (convert-from-foreign (foreign-slot-value (pointer widget) '%gtk-widget :state) 'state-type))
41 (export 'widget-state)
43 (defun widget-saved-state (widget)
44 (convert-from-foreign (foreign-slot-value (pointer widget) '%gtk-widget :saved-state) 'state-type))
46 (export 'widget-saved-state)
48 (defmacro widget-p-fn (type)
49 (let ((name (intern (format nil "WIDGET-~A-P" (symbol-name type)) (find-package :gtk))))
50 `(progn (defun ,name (widget)
51 (member ,type (widget-flags widget)))
54 (widget-p-fn :toplevel)
55 (widget-p-fn :no-window)
56 (widget-p-fn :realized)
58 (widget-p-fn :visible)
59 (widget-p-fn :sensitive)
60 (widget-p-fn :parent-sensitive)
61 (widget-p-fn :can-focus)
62 (widget-p-fn :has-focus)
63 (widget-p-fn :can-default)
64 (widget-p-fn :has-default)
65 (widget-p-fn :has-grab)
66 (widget-p-fn :rc-style)
67 (widget-p-fn :composite-child)
68 (widget-p-fn :no-reparent)
69 (widget-p-fn :app-paintable)
70 (widget-p-fn :receives-default)
71 (widget-p-fn :double-buffered)
72 (widget-p-fn :no-show-all)
74 (defcfun (widget-unparent "gtk_widget_unparent") :void
77 (export 'widget-unparent)
79 (defcfun gtk-widget-show :void
82 (defcfun gtk-widget-show-all :void
85 (defun widget-show (widget &key (all t))
87 (gtk-widget-show-all widget)
88 (gtk-widget-show widget)))
92 (defcfun (widget-show-now "gtk_widget_show_now") :void
95 (export 'widget-show-now)
97 (defcfun gtk-widget-hide :void
100 (defcfun gtk-widget-hide-all :void
103 (defun widget-hide (widget &key (all t))
105 (gtk-widget-hide-all widget)
106 (gtk-widget-hide widget)))
108 (export 'widget-hide)
110 (defcfun (widget-map "gtk_widget_map") :void
115 (defcfun (widget-unmap "gtk_widget_unmap") :void
118 (export 'widget-unmap)
120 (defcfun (widget-realize "gtk_widget_realize") :void
123 (export 'widget-realize)
125 (defcfun (widget-unrealize "gtk_widget_unrealize") :void
128 (export 'widget-unrealize)
130 (defcfun (widget-queue-draw "gtk_widget_queue_draw") :void
131 (widget (g-object widget)))
133 (export 'widget-queue-draw)
135 (defcfun (widget-queue-resize "gtk_widget_queue_resize") :void
136 (widget (g-object widget)))
138 (export 'widget-queue-resize)
140 (defcfun (widget-queue-resize-no-redraw "gtk_widget_queue_resize_no_redraw") :void
141 (widget (g-object widget)))
143 (export 'widget-queue-resize-no-redraw)
145 ; TODO: gtk_widget_get_child_requisition
147 ; TODO: gtk_widget_size_allocate
149 (defcfun (widget-add-accelerator "gtk_widget_add_accelerator") :void
151 (accel-signal :string)
152 (accel-group g-object)
154 (accel-mods modifier-type)
155 (accel-flags accel-flags))
157 (export 'widget-add-accelerator)
159 (defcfun (widget-remove-accelerator "gtk_widget_remove_accelerator") :void
161 (accel-group g-object)
163 (accel-mods modifier-type))
165 (export 'widget-remove-accelerator)
167 (defcfun (widget-set-accel-path "gtk_widget_set_accel_path") :void
170 (accel-group g-object))
172 (export 'widget-set-accel-path)
174 ; TODO: gtk_widget_list_accel_closures
176 (defcfun gtk-widget-can-activate-accel :boolean
180 (defun widget-can-activate-accel (widget signal)
181 (when (stringp signal) (setf signal (g-signal-lookup signal (g-type-from-object widget))))
182 (gtk-widget-can-activate-accel widget signal))
184 (export 'widget-can-activate-accel)
186 (defcfun (widget-event "gtk_widget_event") :boolean
187 (widget (g-object widget))
188 (event (g-boxed-foreign event)))
190 (export 'widget-event)
192 (defcfun (widget-activate "gtk_widget_activate") :boolean
195 (export 'widget-activate)
197 (defcfun (widget-reparent "gtk_widget_reparent") :void
199 (new-parent g-object))
201 (export 'widget-reparent)
203 (defcfun gtk-widget-intersect :boolean
205 (area (g-boxed-foreign rectangle))
206 (intersection (g-boxed-foreign rectangle)))
208 (defun widget-intersect (widget rectangle)
209 (let ((result (make-rectangle)))
210 (when (gtk-widget-intersect widget rectangle result)
213 (export 'widget-intersect)
215 (defcfun (widget-focus-p "gtk_widget_is_focus") :boolean
218 (export 'widget-focus-p)
220 (defcfun (widget-grab-focus "gtk_widget_grab_focus") :void
223 (export 'widget-grab-focus)
225 (defcfun (widget-grab-default "gtk_widget_grab_default") :void
228 (export 'widget-grab-default)
230 (defcfun (widget-set-state "gtk_widget_set_state") :void
231 (widget (g-object widget))
234 (export 'widget-set-state)
236 (defcfun (widget-ancestor "gtk_widget_get_ancestor") (g-object widget)
237 (widget (g-object widget))
238 (type g-type-designator))
240 (export 'widget-ancestor)
242 (defcfun gtk-widget-get-pointer :void
247 (defun widget-pointer (widget)
248 (with-foreign-objects ((x :int) (y :int))
249 (gtk-widget-get-pointer widget x y)
250 (values (mem-ref x :int) (mem-ref y :int))))
252 (export 'widget-pointer)
254 (defcfun (widget-is-ancestor "gtk_widget_is_ancestor") :boolean
256 (container g-object))
258 (export 'widget-is-ancestor)
260 (defcfun gtk-widget-translate-coordinates :boolean
261 (src-widget g-object)
262 (dst-widget g-object)
265 (dst-x (:pointer :int))
266 (dst-y (:pointer :int)))
268 (defun widget-translate-coordinates (src-widget dst-widget src-x src-y)
269 (with-foreign-objects ((dst-x :int) (dst-y :int))
270 (gtk-widget-translate-coordinates src-widget dst-widget src-x src-y dst-x dst-y)
271 (values (mem-ref dst-x :int)
272 (mem-ref dst-y :int))))
274 (export 'widget-translate-coordinates)
276 (defcfun (widget-ensure-style "gtk_widget_ensure_style") :void
279 (export 'widget-ensure-style)
281 (defcfun (widget-reset-rc-styles "gtk_widget_reset_rc_styles") :void
284 (export 'widget-reset-rc-styles)
286 (defcfun (widget-push-colormap "gtk_widget_push_colormap") :void
287 (colormap (g-object gdk-colormap)))
289 (export 'widget-push-colormap)
291 (defcfun (widget-pop-colormap "gtk_widget_pop_colormap") :void)
293 (export 'widget-pop-colormap)
295 (defcfun (widget-default-colormap "gtk_widget_get_default_colormap") (g-object gdk-colormap))
297 (defcfun gtk-widget-set-default-colormap :void
298 (colormap (g-object gdk-colormap)))
300 (defun (setf widget-default-colormap) (colormap)
301 (gtk-widget-set-default-colormap colormap))
303 (export 'widget-default-colormap)
305 (defcfun (widget-default-style "gtk_widget_get_default_style") (g-object style))
307 (export 'widget-default-style)
309 (defcfun (widget-default-visual "gtk_widget_get_default_visual") (g-object visual))
311 (export 'widget-default-visual)
313 (defcfun (widget-default-direction "gtk_widget_get_default_direction") text-direction)
315 (defcfun gtk-widget-set-default-direction :void
316 (direction text-direction))
318 (defun (setf widget-default-direction) (new-value)
319 (gtk-widget-set-default-direction new-value))
321 (export 'widget-default-direction)
323 (defcfun (widget-shape-combine-mask "gtk_widget_shape_combine_mask") :void
324 (widget (g-object widget))
325 (shape-mask g-object)
329 (export 'widget-shape-combine-mask)
331 (defcfun (widget-input-shape-combine-mask "gtk_widget_input_shape_combine_mask") :void
332 (widget (g-object widget))
333 (shape-mask g-object)
337 (export 'widget-input-shape-combine-mask)
339 (defcfun gtk-widget-path :void
341 (path-length (:pointer :uint))
342 (path (:pointer (:pointer :char)))
343 (path-reversed (:pointer (:pointer :char))))
345 (defcfun gtk-widget-class-path :void
347 (path-length (:pointer :uint))
348 (path (:pointer (:pointer :char)))
349 (path-reversed (:pointer (:pointer :char))))
351 (defun widget-path (widget &key (path-type :name))
352 (assert (typep path-type '(member :name :class)))
353 (with-foreign-object (path :pointer)
355 (:name (gtk-widget-path widget (null-pointer) path (null-pointer)))
356 (:class (gtk-widget-class-path widget (null-pointer) path (null-pointer))))
357 (mem-ref path '(g-string :free-from-foreign t))))
359 (export 'widget-path)
361 (defcfun (widget-modify-fg "gtk_widget_modify_fg") :void
362 (widget (g-object widget))
364 (color (g-boxed-foreign color)))
366 (export 'widget-modify-fg)
368 (defcfun (widget-modify-bg "gtk_widget_modify_bg") :void
369 (widget (g-object widget))
371 (color (g-boxed-foreign color)))
373 (export 'widget-modify-bg)
375 (defcfun (widget-modify-text "gtk_widget_modify_text") :void
376 (widget (g-object widget))
378 (color (g-boxed-foreign color)))
380 (export 'widget-modify-text)
382 (defcfun (widget-modify-base "gtk_widget_modify_base") :void
383 (widget (g-object widget))
385 (color (g-boxed-foreign color)))
387 (export 'widget-modify-base)
389 ;void gtk_widget_modify_font (GtkWidget *widget,
390 ; PangoFontDescription *font_desc);
392 (defcfun (widget-modify-cursor "gtk_widget_modify_cursor") :void
393 (widget (g-object widget))
394 (primary (g-boxed-foreign color))
395 (secondary (g-boxed-foreign color)))
397 (export 'widget-modify-cursor)
399 (defcfun (widget-create-pango-context "gtk_widget_create_pango_context") (g-object :already-referenced)
402 (export 'widget-create-pango-context)
404 (defcfun (widget-create-pango-layout "gtk_widget_create_pango_layout") (g-object pango-layout :already-referenced)
405 (widget (g-object widget))
408 (export 'widget-create-pango-layout)
410 (defcfun (widget-render-icon "gtk_widget_render_icon") g-object
416 (export 'widget-render-icon)
418 (defcfun (widget-push-composite-child "gtk_widget_push_composite_child") :void
421 (export 'widget-push-composite-child)
423 (defcfun (widget-pop-composite-child "gtk_widget_pop_composite_child") :void
426 (export 'widget-pop-composite-child)
428 (defcfun (widget-queue-clear "gtk_widget_queue_clear") :void
429 (widget (g-object widget)))
431 (export 'widget-queue-clear)
433 (defcfun (widget-queue-clear-area "gtk_widget_queue_clear_area") :void
434 (widget (g-object widget))
440 (export 'widget-queue-clear-area)
442 (defcfun (widget-queue-draw-area "gtk_widget_queue_draw_area") :void
449 (export 'widget-queue-draw-area)
451 (defcfun (widget-reset-shapes "gtk_widget_reset_shapes") :void
454 (export 'widget-reset-shapes)
456 (defcfun (widget-set-double-buffered "gtk_widget_set_double_buffered") :void
457 (widget (g-object widget))
458 (double-buffered :boolean))
460 (export 'widget-set-double-buffered)
462 (defcfun (widget-set-scroll-adjustments "gtk_widget_set_scroll_adjustments") :boolean
464 (hadjustment g-object)
465 (vadjustment g-object))
467 (export 'widget-set-scroll-adjustments)
469 (defcfun (widget-mnemonic-activate "gtk_widget_mnemonic_activate") :boolean
470 (widget (g-object widget))
471 (group-cycling :boolean))
473 (export 'widget-mnemonic-activate)
475 ; TODO: gtk_widget_class_install_style_property
477 ; TOOD: gtk_widget_class_install_style_property_parser
479 ; TODO: gtk_widget_class_list_style_properties
481 (defcfun (widget-region-intersect "gtk_widget_region_intersect") (g-boxed-foreign region :return)
482 (widget (g-object widget))
483 (region (g-boxed-foreign region)))
485 (export 'widget-region-intersect)
487 ; ignored: gtk_widget_send_expose
489 (defcfun gtk-widget-style-get-property :void
491 (property-name :string)
492 (value (:pointer g-value)))
494 (defcfun gtk-widget-class-find-style-property (:pointer g-param-spec)
496 (property-name :string))
498 (defcfun gtk-widget-class-list-style-properties (:pointer (:pointer g-param-spec))
500 (n-properties (:pointer :int)))
502 (defun widget-get-style-properties (type)
503 (setf type (gtype type))
504 (let ((class (g-type-class-ref type)))
506 (with-foreign-object (np :int)
507 (let ((specs (gtk-widget-class-list-style-properties class np)))
510 repeat (mem-ref np :int)
512 for spec = (mem-aref specs :pointer i)
513 collect (parse-g-param-spec spec))
515 (g-type-class-unref class))))
517 (export 'widget-get-style-properties)
519 (defun widget-style-property-info (type property-name)
520 (let ((class (g-type-class-ref type)))
522 (let ((g-param-spec (gtk-widget-class-find-style-property class property-name)))
523 (parse-g-param-spec g-param-spec))
524 (g-type-class-unref class))))
526 (export 'widget-style-property-info)
528 (defun widget-style-property-type (widget property-name)
529 (let ((property-info (widget-style-property-info (g-type-from-object widget) property-name)))
530 (g-class-property-definition-type property-info)))
532 (defun widget-style-property-value (widget property-name &optional property-type)
533 (unless property-type (setf property-type (widget-style-property-type widget property-name)))
534 (setf property-type (gtype property-type))
535 (with-foreign-object (gvalue 'g-value)
536 (g-value-zero gvalue)
537 (g-value-init gvalue property-type)
538 (prog1 (gtk-widget-style-get-property widget property-name gvalue)
539 (g-value-unset gvalue))))
541 (export 'widget-style-property-value)
543 (defcfun (widget-child-focus "gtk_widget_child_focus") :boolean
545 (direction direction-type))
547 (export 'widget-child-focus)
549 (defcfun (widget-child-notify "gtk_widget_child_notify") :void
550 (widget (g-object widget))
551 (property-name :string))
553 (export 'widget-child-notify)
555 (defcfun (widget-freeze-child-notify "gtk_widget_freeze_child_notify") :void
558 (export 'widget-freeze-child-notify)
560 (defcfun (widget-settings "gtk_widget_get_settings") g-object
563 (export 'widget-settings)
565 (defcfun (widget-clipboard "gtk_widget_get_clipboard") (g-object clipboard)
566 (widget (g-object widget))
567 (selection gdk-atom-as-string))
569 (export 'widget-clipboard)
571 (defcfun (widget-display "gtk_widget_get_display") g-object
574 (export 'widget-display)
576 (defcfun (widget-root-window "gtk_widget_get_root_window") g-object
579 (export 'widget-root-window)
581 (defcfun (widget-screen "gtk_widget_get_screen") g-object
584 (export 'widget-screen)
586 (defcfun (widget-has-screen "gtk_widget_has_screen") :boolean
589 (export 'widget-has-screen)
591 (defcfun (widget-thaw-child-notify "gtk_widget_thaw_child_notify") :void
594 (export 'widget-thaw-child-notify)
596 (defcfun (widget-mnemonic-labels "gtk_widget_list_mnemonic_labels") (glist (g-object widget) :free-from-foreign t)
597 (widget (g-object widget)))
599 (export 'widget-mnemonic-labels)
601 (defcfun (widget-add-mnemonic-label "gtk_widget_add_mnemonic_label") :void
605 (export 'widget-add-mnemonic-label)
607 (defcfun (widget-remove-mnemonic-label "gtk_widget_remove_mnemonic_label") :void
611 (export 'widget-remove-mnemonic-label)
613 (defcfun (widget-action "gtk_widget_get_action") g-object
616 (export 'widget-action)
618 (defcfun (widget-composited-p "gtk_widget_is_composited") :boolean
621 (export 'widget-composited-p)
623 (defcfun (widget-error-bell "gtk_widget_error_bell") :void
626 (export 'widget-error-bell)
628 (defcfun (widget-trigger-tooltip-query "gtk_tooltip_trigger_tooltip_query") :void
631 (export 'widget-trigger-tooltip-query)
633 (defcfun gtk-widget-get-snapshot g-object
635 (clip-rectangle (g-boxed-foreign rectangle)))
637 (defun widget-snapshot (widget &optional clip-rectangle)
638 (gtk-widget-get-snapshot widget clip-rectangle))
640 (export 'widget-snapshot)