(C-array-loc! alien "GdkColor" (C-enum "GTK_STATE_NORMAL"))
;; The GdkColor was allocated by the GtkStyle.
(C-call "gdk_window_set_background" (fix-widget-window widget) alien))))
+
+(define-syntax pointer-shapes
+ (sc-macro-transformer
+ (lambda (form usage-env)
+
+ (define (simplify name)
+ ;; |GDK_BASED_ARROW_DOWN| => based-arrow-down
+ (let ((string (symbol-name name)))
+ (if (string-prefix? "GDK_" string)
+ (intern (string-replace (string-tail string 4) #\_ #\-))
+ (begin
+ (warn "Unexpected GdkCursorType name:" name)
+ name))))
+
+ (list 'quote
+ (map (lambda (name.value)
+ (cons (simplify (car name.value))
+ (cdr name.value)))
+ (c-enum-constant-values '|GdkCursorType| form
+ (find-c-includes usage-env)))))))
+
+(define set-fix-widget-pointer-shape!
+ (let ((alist (pointer-shapes)))
+ (named-lambda (set-fix-widget-pointer-shape! widget name)
+ (let ((name.value (or (assq name alist)
+ (error "Not a pointer shape:" name
+ (map car alist))))
+ (alien (make-alien '|GdkCursor|)))
+ ;; Not GC-protecting alien?
+ (C-call "gdk_cursor_new" alien (cdr name.value))
+ (C-call "gdk_window_set_cursor" (fix-widget-window widget) alien)
+ (C-call "gdk_cursor_unref" alien)))))
\f
(define (event-callback widget GdkEvent)
(%trace2 ";event-callback "widget)
(declare (ignore GdkEvent))
(handler widget))))
+(define (set-fix-widget-enter-notify-handler! widget handler)
+ (guarantee-fix-widget widget 'set-fix-widget-enter-notify-handler!)
+ (guarantee-procedure-of-arity handler 1 'set-fix-widget-enter-notify-handler!)
+ (vector-set!
+ (fix-widget-event-handlers widget) (C-enum "GDK_ENTER_NOTIFY")
+ (named-lambda (fix-widget-enter-notify-handler widget GdkEvent)
+ (declare (ignore GdkEvent))
+ (handler widget))))
+
+(define (set-fix-widget-leave-notify-handler! widget handler)
+ (guarantee-fix-widget widget 'set-fix-widget-leave-notify-handler!)
+ (guarantee-procedure-of-arity handler 1 'set-fix-widget-leave-notify-handler!)
+ (vector-set!
+ (fix-widget-event-handlers widget) (C-enum "GDK_LEAVE_NOTIFY")
+ (named-lambda (fix-widget-leave-notify-handler widget GdkEvent)
+ (declare (ignore GdkEvent))
+ (handler widget))))
+
(define (set-fix-widget-focus-change-handler! widget handler)
(guarantee-fix-widget widget 'set-fix-widget-focus-change-handler!)
(guarantee-procedure-of-arity handler 2 'set-fix-widget-focus-change-handler!)
(define-guarantee fix-layout "a <fix-layout>")
(define-method initialize-instance ((widget <fix-layout>) width height)
-
(call-next-method widget width height)
(%trace "; (initialize-instance <fix-layout>) "widget" "width" "height"\n")
(set-fix-widget-expose-handler! widget layout-expose-handler)
(define-class (<fix-resizer> (constructor () (width height)))
(<fix-widget>))
-(define-method initialize-instance ((widget <fix-resizer>) width height)
- (call-next-method widget width height)
- (set-fix-widget-expose-handler! widget resizer-expose-handler))
+(define-method fix-widget-realize-callback ((widget <fix-resizer>))
+ (call-next-method widget)
+ (%trace "; (fix-widget-realize-callback <fix-resizer>) "widget"\n")
+ (let ((geom (fix-widget-geometry widget)))
+ (set-fix-widget-pointer-shape!
+ widget (if (fix:< (fix-rect-width geom)
+ (fix-rect-height geom))
+ 'sb-h-double-arrow
+ 'sb-v-double-arrow)))
+ (set-fix-widget-expose-handler! widget resizer-expose-handler)
+ (set-fix-widget-enter-notify-handler! widget resizer-enter-handler)
+ (set-fix-widget-leave-notify-handler! widget resizer-leave-handler))
(define (resizer-expose-handler resizer x y width height)
+ (declare (ignore x y width height))
(let ((alien (gobject-alien resizer)))
(let ((style (C-> alien "GtkWidget style"))
(window (fix-widget-window resizer))
(fix-rect-width geom) (fix-rect-height geom)
orientation)
#t))))
+
+(define (resizer-enter-handler resizer)
+ (outf-error ";resizer-enter-handler\n")
+ (C-call "gtk_widget_set_state"
+ (gobject-alien resizer) (C-enum "GTK_STATE_PRELIGHT")))
+
+(define (resizer-leave-handler resizer)
+ (outf-error ";resizer-leave-handler\n")
+ (C-call "gtk_widget_set_state"
+ (gobject-alien resizer) (C-enum "GTK_STATE_NORMAL")))
\f
(define-class (<fix-drawing> (constructor () no-init))
()
(loader define standard initializer make-pixbuf-loader))
(define-method initialize-instance ((ink <image-ink>))
- (%trace ";(initialize-instance <image-ink>) "ink"\n")
(call-next-method ink)
+ (%trace ";(initialize-instance <image-ink>) "ink"\n")
(let ((loader (image-ink-loader ink)))
(set-pixbuf-loader-size-hook! loader (image-ink-size-prepared ink))
(set-pixbuf-loader-pixbuf-hook! loader (image-ink-pixbuf-prepared ink))
(define-package (gtk fix-layout)
(parent (gtk))
(files "fix-layout")
- ;;(depends-on "pango" "gtk.bin" "gtk" "../runtime/ffi")
+ ;;(depends-on "pango" "gtk.bin" gtk" "../runtime/ffi" "gtk-const.bin")
+ (import (ffi)
+ find-c-includes
+ c-enum-constant-values)
(import (gtk pango)
make-pango-layout pango-rectangle pangos->pixels pixels->pangos)
(import (gtk gtk-object)
fix-widget?
fix-widget-new-geometry-callback fix-widget-realize-callback
set-fix-widget-size!
+ set-fix-widget-pointer-shape!
set-fix-widget-expose-handler!
set-fix-widget-map-handler!
set-fix-widget-unmap-handler!
+ set-fix-widget-enter-notify-handler!
+ set-fix-widget-leave-notify-handler!
set-fix-widget-focus-change-handler!
set-fix-widget-visibility-notify-handler!
set-fix-widget-key-press-handler!
(define-package (gtk keys)
(parent (gtk))
(files "keys")
- ;;(depends-on "gtk.bin" "gtk" "../runtime/ffi")
+ ;;(depends-on "gtk.bin" "gtk" "../runtime/ffi" "gtk-const.bin")
(export (gtk)
gdk-key-state->char-bits
gdk-keyval->name)