Created
May 13, 2020 07:46
-
-
Save spdegabrielle/1e76357f8ef45a806f02c909758b09d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/gui | |
(require ffi/unsafe | |
ffi/unsafe/objc | |
pict pict/face) | |
;; Create the frame: | |
(define f (new frame% | |
[label "Example"] | |
[width 400] | |
[height 400])) | |
;; Add a transparent canvas that displays "Hello" | |
(new canvas% | |
[parent f] | |
[style '(transparent)] | |
[paint-callback (lambda (c dc) | |
(send dc draw-text "Hello" 0 0) | |
(draw-pict (face 'happy) dc 10 15))]) | |
;; The `CGFloat` type depends on the platform: | |
(define 64-bit? (= (ctype-sizeof _long) 8)) | |
(define _CGFloat (if 64-bit? _double _float)) | |
;; Get an `NSWindow` from the `frame%` object: | |
(define h (send f get-handle)) | |
;; Set the background's transparency at the `NSWindow` level: | |
(import-class NSColor) | |
(tellv h setBackgroundColor: (tell NSColor | |
colorWithRed: #:type _CGFloat 1.0 | |
green: #:type _CGFloat 1.0 | |
blue: #:type _CGFloat 1.0 | |
alpha: #:type _CGFloat 0.0)) | |
;(tell h titlebarAppearsTransparent: #:type _BOOL YES) | |
;var titlebarAppearsTransparent: Bool | |
(tellv h setOpaque: #:type _BOOL NO) | |
;; Show the frame: | |
(send f show #t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
found in racket-users archive (2014?)