fix canvases in tab panels
This commit is contained in:
parent
d7289c253f
commit
82c0a1cc29
|
@ -16,25 +16,16 @@
|
||||||
|
|
||||||
(define (panel-mixin %)
|
(define (panel-mixin %)
|
||||||
(class %
|
(class %
|
||||||
|
(inherit register-as-child)
|
||||||
|
|
||||||
(define lbl-pos 'horizontal)
|
(define lbl-pos 'horizontal)
|
||||||
|
(define children null)
|
||||||
|
|
||||||
(super-new)
|
(super-new)
|
||||||
|
|
||||||
(define/public (get-label-position) lbl-pos)
|
(define/public (get-label-position) lbl-pos)
|
||||||
(define/public (set-label-position pos) (set! lbl-pos pos))
|
(define/public (set-label-position pos) (set! lbl-pos pos))
|
||||||
|
|
||||||
(def/public-unimplemented on-paint)
|
|
||||||
(define/public (set-item-cursor x y) (void))
|
|
||||||
(def/public-unimplemented get-item-cursor)))
|
|
||||||
|
|
||||||
(defclass panel% (panel-mixin window%)
|
|
||||||
(init parent
|
|
||||||
x y w h
|
|
||||||
style
|
|
||||||
label)
|
|
||||||
(inherit register-as-child)
|
|
||||||
|
|
||||||
(define children null)
|
|
||||||
|
|
||||||
(define/public (fix-dc)
|
(define/public (fix-dc)
|
||||||
(for ([child (in-list children)])
|
(for ([child (in-list children)])
|
||||||
(send child fix-dc)))
|
(send child fix-dc)))
|
||||||
|
@ -54,6 +45,15 @@
|
||||||
(cons child children)
|
(cons child children)
|
||||||
(remq child children))))))
|
(remq child children))))))
|
||||||
|
|
||||||
|
(def/public-unimplemented on-paint)
|
||||||
|
(define/public (set-item-cursor x y) (void))
|
||||||
|
(def/public-unimplemented get-item-cursor)))
|
||||||
|
|
||||||
|
(defclass panel% (panel-mixin window%)
|
||||||
|
(init parent
|
||||||
|
x y w h
|
||||||
|
style
|
||||||
|
label)
|
||||||
(super-new [parent parent]
|
(super-new [parent parent]
|
||||||
[cocoa
|
[cocoa
|
||||||
(as-objc-allocation
|
(as-objc-allocation
|
||||||
|
|
|
@ -84,7 +84,8 @@
|
||||||
[ignored-name #f]
|
[ignored-name #f]
|
||||||
[gl-config #f])
|
[gl-config #f])
|
||||||
|
|
||||||
(inherit get-gtk set-size get-client-size)
|
(inherit get-gtk set-size get-size get-client-size
|
||||||
|
on-size register-as-child)
|
||||||
|
|
||||||
(define client-gtk (gtk_drawing_area_new))
|
(define client-gtk (gtk_drawing_area_new))
|
||||||
(define-values (gtk hscroll-adj vscroll-adj hscroll-gtk vscroll-gtk resize-box)
|
(define-values (gtk hscroll-adj vscroll-adj hscroll-gtk vscroll-gtk resize-box)
|
||||||
|
@ -197,8 +198,18 @@
|
||||||
(define/override (refresh)
|
(define/override (refresh)
|
||||||
(gtk_widget_queue_draw client-gtk))
|
(gtk_widget_queue_draw client-gtk))
|
||||||
|
|
||||||
|
(define/public (reset-child-dcs)
|
||||||
|
(send dc reset-dc #t))
|
||||||
|
(define/override (maybe-register-as-child parent on?)
|
||||||
|
(register-as-child parent on?))
|
||||||
|
|
||||||
(define/override (internal-on-client-size w h)
|
(define/override (internal-on-client-size w h)
|
||||||
(send dc reset-dc-size))
|
(send dc reset-dc #f))
|
||||||
|
(define/override (on-client-size w h)
|
||||||
|
(let ([xb (box 0)]
|
||||||
|
[yb (box 0)])
|
||||||
|
(get-size xb yb)
|
||||||
|
(on-size (unbox xb) (unbox yb))))
|
||||||
|
|
||||||
(define/public (show-scrollbars h? v?)
|
(define/public (show-scrollbars h? v?)
|
||||||
(when hscroll-gtk
|
(when hscroll-gtk
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
racket/draw/local
|
racket/draw/local
|
||||||
ffi/unsafe/alloc)
|
ffi/unsafe/alloc)
|
||||||
|
|
||||||
(provide dc% reset-dc-size)
|
(provide dc% reset-dc)
|
||||||
|
|
||||||
(define-gdk gdk_cairo_create (_fun _pointer -> _cairo_t)
|
(define-gdk gdk_cairo_create (_fun _pointer -> _cairo_t)
|
||||||
#:wrap (allocator cairo_destroy))
|
#:wrap (allocator cairo_destroy))
|
||||||
|
|
||||||
(define-local-member-name
|
(define-local-member-name
|
||||||
reset-dc-size)
|
reset-dc)
|
||||||
|
|
||||||
(define dc-backend%
|
(define dc-backend%
|
||||||
(class default-dc-backend%
|
(class default-dc-backend%
|
||||||
|
@ -31,8 +31,9 @@
|
||||||
(set! c (gdk_cairo_create w))
|
(set! c (gdk_cairo_create w))
|
||||||
c))))
|
c))))
|
||||||
|
|
||||||
(define/public (reset-dc-size)
|
(define/public (reset-dc force?)
|
||||||
(when (eq? 'windows (system-type))
|
(when (or force?
|
||||||
|
(eq? 'windows (system-type)))
|
||||||
;; FIXME: ensure that the dc is not in use
|
;; FIXME: ensure that the dc is not in use
|
||||||
(as-entry
|
(as-entry
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
|
@ -17,12 +17,36 @@
|
||||||
|
|
||||||
(define (panel-mixin %)
|
(define (panel-mixin %)
|
||||||
(class %
|
(class %
|
||||||
(define lbl-pos 'vertical)
|
(inherit register-as-child)
|
||||||
|
|
||||||
|
(define lbl-pos 'horizontal)
|
||||||
|
(define children null)
|
||||||
|
|
||||||
(super-new)
|
(super-new)
|
||||||
|
|
||||||
(define/public (get-label-position) lbl-pos)
|
(define/public (get-label-position) lbl-pos)
|
||||||
(define/public (set-label-position pos) (set! lbl-pos pos))
|
(define/public (set-label-position pos) (set! lbl-pos pos))
|
||||||
|
|
||||||
|
(define/public (reset-child-dcs)
|
||||||
|
(when (pair? children)
|
||||||
|
(for ([child (in-list children)])
|
||||||
|
(send child reset-child-dcs))))
|
||||||
|
|
||||||
|
(define/override (set-size x y w h)
|
||||||
|
(super set-size x y w h)
|
||||||
|
(reset-child-dcs))
|
||||||
|
|
||||||
|
(define/override (maybe-register-as-child parent on?)
|
||||||
|
(register-as-child parent on?))
|
||||||
|
|
||||||
|
(define/override (register-child child on?)
|
||||||
|
(let ([now-on? (and (memq child children) #t)])
|
||||||
|
(unless (eq? on? now-on?)
|
||||||
|
(set! children
|
||||||
|
(if on?
|
||||||
|
(cons child children)
|
||||||
|
(remq child children))))))
|
||||||
|
|
||||||
(def/public-unimplemented on-paint)
|
(def/public-unimplemented on-paint)
|
||||||
(define/public (set-item-cursor x y) (void))
|
(define/public (set-item-cursor x y) (void))
|
||||||
(def/public-unimplemented get-item-cursor)))
|
(def/public-unimplemented get-item-cursor)))
|
||||||
|
|
|
@ -45,7 +45,8 @@
|
||||||
style
|
style
|
||||||
labels)
|
labels)
|
||||||
|
|
||||||
(inherit set-size set-auto-size get-gtk)
|
(inherit set-size set-auto-size get-gtk
|
||||||
|
reset-child-dcs)
|
||||||
|
|
||||||
(define gtk (gtk_notebook_new))
|
(define gtk (gtk_notebook_new))
|
||||||
;; Reparented so that it's always in the current page's bin:
|
;; Reparented so that it's always in the current page's bin:
|
||||||
|
@ -56,7 +57,9 @@
|
||||||
|
|
||||||
(define (select-bin bin-gtk)
|
(define (select-bin bin-gtk)
|
||||||
(set! current-bin-gtk bin-gtk)
|
(set! current-bin-gtk bin-gtk)
|
||||||
(gtk_box_pack_start bin-gtk client-gtk #t #t 0))
|
(gtk_box_pack_start bin-gtk client-gtk #t #t 0)
|
||||||
|
;; re-parenting can change the underlying window dc:
|
||||||
|
(reset-child-dcs))
|
||||||
|
|
||||||
(define pages
|
(define pages
|
||||||
(for/list ([lbl labels])
|
(for/list ([lbl labels])
|
||||||
|
|
|
@ -255,7 +255,8 @@
|
||||||
(if on?
|
(if on?
|
||||||
(gtk_widget_show gtk)
|
(gtk_widget_show gtk)
|
||||||
(gtk_widget_hide gtk))
|
(gtk_widget_hide gtk))
|
||||||
(set! shown? (and on? #t)))
|
(set! shown? (and on? #t))
|
||||||
|
(maybe-register-as-child parent on?))
|
||||||
(define/public (show on?)
|
(define/public (show on?)
|
||||||
(direct-show on?))
|
(direct-show on?))
|
||||||
(define/public (is-shown?) shown?)
|
(define/public (is-shown?) shown?)
|
||||||
|
@ -325,8 +326,16 @@
|
||||||
(define/public (on-char e) (void))
|
(define/public (on-char e) (void))
|
||||||
(define/public (on-event e) (void))
|
(define/public (on-event e) (void))
|
||||||
|
|
||||||
|
(define/public (on-size w h) (void))
|
||||||
|
|
||||||
|
(define/public (maybe-register-as-child parent on?)
|
||||||
|
(void))
|
||||||
|
(define/public (register-as-child parent on?)
|
||||||
|
(send parent register-child this on?))
|
||||||
|
(define/public (register-child child on?)
|
||||||
|
(void))
|
||||||
|
|
||||||
(def/public-unimplemented on-drop-file)
|
(def/public-unimplemented on-drop-file)
|
||||||
(def/public-unimplemented on-size)
|
|
||||||
(def/public-unimplemented get-handle)
|
(def/public-unimplemented get-handle)
|
||||||
(def/public-unimplemented set-phantom-size)
|
(def/public-unimplemented set-phantom-size)
|
||||||
(def/public-unimplemented popup-menu)
|
(def/public-unimplemented popup-menu)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user