dialog show & button width fixes
This commit is contained in:
parent
b9eb058cec
commit
202e18ef85
|
@ -42,7 +42,8 @@
|
||||||
(dynamic-wind
|
(dynamic-wind
|
||||||
void
|
void
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(send af on-exit)
|
(as-exit (lambda ()
|
||||||
|
(send af on-exit)))
|
||||||
(unless (null? (wx:get-top-level-windows))
|
(unless (null? (wx:get-top-level-windows))
|
||||||
(wx:cancel-quit)))
|
(wx:cancel-quit)))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
|
@ -14,19 +14,22 @@
|
||||||
(objc-unsafe!)
|
(objc-unsafe!)
|
||||||
|
|
||||||
(provide button%
|
(provide button%
|
||||||
|
core-button%
|
||||||
MyButton)
|
MyButton)
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
(import-class NSButton NSView NSImageView)
|
(import-class NSButton NSView NSImageView)
|
||||||
|
|
||||||
|
(define MIN-BUTTON-WIDTH 72)
|
||||||
|
|
||||||
(define-objc-class MyButton NSButton
|
(define-objc-class MyButton NSButton
|
||||||
#:mixins (FocusResponder)
|
#:mixins (FocusResponder)
|
||||||
[wx]
|
[wx]
|
||||||
(-a _void (clicked: [_id sender])
|
(-a _void (clicked: [_id sender])
|
||||||
(queue-window-event wx (lambda () (send wx clicked)))))
|
(queue-window-event wx (lambda () (send wx clicked)))))
|
||||||
|
|
||||||
(defclass button% item%
|
(defclass core-button% item%
|
||||||
(init parent cb label x y w h style font
|
(init parent cb label x y w h style font
|
||||||
[button-type #f])
|
[button-type #f])
|
||||||
(init-field [event-type 'button])
|
(init-field [event-type 'button])
|
||||||
|
@ -55,6 +58,14 @@
|
||||||
(tellv cocoa setTitle: #:type _NSString "<bad>")])
|
(tellv cocoa setTitle: #:type _NSString "<bad>")])
|
||||||
(init-font cocoa font)
|
(init-font cocoa font)
|
||||||
(tellv cocoa sizeToFit)
|
(tellv cocoa sizeToFit)
|
||||||
|
(when (and (eq? event-type 'button)
|
||||||
|
(string? label))
|
||||||
|
(let ([frame (tell #:type _NSRect cocoa frame)])
|
||||||
|
(when ((NSSize-width (NSRect-size frame)) . < . MIN-BUTTON-WIDTH)
|
||||||
|
(tellv cocoa setFrame: #:type _NSRect
|
||||||
|
(make-NSRect (NSRect-origin frame)
|
||||||
|
(make-NSSize MIN-BUTTON-WIDTH
|
||||||
|
(NSSize-height (NSRect-size frame))))))))
|
||||||
cocoa))
|
cocoa))
|
||||||
|
|
||||||
(define cocoa (if (and button-type
|
(define cocoa (if (and button-type
|
||||||
|
@ -119,3 +130,7 @@
|
||||||
[time-stamp (current-milliseconds)])))
|
[time-stamp (current-milliseconds)])))
|
||||||
|
|
||||||
(def/public-unimplemented set-border))
|
(def/public-unimplemented set-border))
|
||||||
|
|
||||||
|
(define button%
|
||||||
|
(class core-button% (super-new)))
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
(defclass check-box% button%
|
(defclass check-box% core-button%
|
||||||
(inherit get-cocoa)
|
(inherit get-cocoa)
|
||||||
(super-new [button-type NSSwitchButton]
|
(super-new [button-type NSSwitchButton]
|
||||||
[event-type 'check-box])
|
[event-type 'check-box])
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(require scheme/class
|
(require scheme/class
|
||||||
"../../syntax.rkt"
|
"../../syntax.rkt"
|
||||||
"../common/queue.rkt"
|
"../common/queue.rkt"
|
||||||
|
"../../lock.rkt"
|
||||||
"frame.rkt")
|
"frame.rkt")
|
||||||
|
|
||||||
(provide dialog%)
|
(provide dialog%)
|
||||||
|
@ -13,19 +14,21 @@
|
||||||
|
|
||||||
(define/override (direct-show on?)
|
(define/override (direct-show on?)
|
||||||
(unless on?
|
(unless on?
|
||||||
|
(as-entry
|
||||||
|
(lambda ()
|
||||||
(when close-sema
|
(when close-sema
|
||||||
(semaphore-post close-sema)
|
(semaphore-post close-sema)
|
||||||
(set! close-sema #f)))
|
(set! close-sema #f)))))
|
||||||
(super direct-show on?))
|
(super direct-show on?))
|
||||||
|
|
||||||
(define/override (show on?)
|
(define/override (show on?)
|
||||||
(if on?
|
(if on?
|
||||||
(unless close-sema
|
(let ([s (as-entry
|
||||||
(let ([s (make-semaphore)])
|
(lambda ()
|
||||||
(set! close-sema s)
|
(let ([s (or close-sema (make-semaphore))])
|
||||||
|
(unless close-sema (set! close-sema s))
|
||||||
|
s)))])
|
||||||
(super show on?)
|
(super show on?)
|
||||||
(yield s)))
|
(yield s)
|
||||||
|
(void))
|
||||||
(super show on?))))
|
(super show on?))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,8 @@
|
||||||
(custodian-shutdown-all c)))))))
|
(custodian-shutdown-all c)))))))
|
||||||
(set! was-menu-bar #f)))
|
(set! was-menu-bar #f)))
|
||||||
|
|
||||||
|
(define o (current-error-port))
|
||||||
|
|
||||||
;; Call this function only in atomic mode:
|
;; Call this function only in atomic mode:
|
||||||
(define (check-one-event wait? dequeue?)
|
(define (check-one-event wait? dequeue?)
|
||||||
(pre-event-sync wait?)
|
(pre-event-sync wait?)
|
||||||
|
|
|
@ -333,4 +333,5 @@
|
||||||
(lambda (k v) k)))
|
(lambda (k v) k)))
|
||||||
|
|
||||||
(define (queue-quit-event)
|
(define (queue-quit-event)
|
||||||
|
;; called in event-pump thread
|
||||||
(queue-event main-eventspace (application-quit-handler) 'med))
|
(queue-event main-eventspace (application-quit-handler) 'med))
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
(provide (protect-out as-entry
|
(provide (protect-out as-entry
|
||||||
as-exit
|
as-exit
|
||||||
entry-point))
|
entry-point
|
||||||
|
|
||||||
|
inside-lock?
|
||||||
|
any-lock?))
|
||||||
|
|
||||||
;; We need atomic mode for a couple of reasons:
|
;; We need atomic mode for a couple of reasons:
|
||||||
;;
|
;;
|
||||||
|
@ -123,3 +126,8 @@
|
||||||
(syntax (case-lambda
|
(syntax (case-lambda
|
||||||
[vars (as-entry (lambda () body1 body ...))]
|
[vars (as-entry (lambda () body1 body ...))]
|
||||||
...))])))
|
...))])))
|
||||||
|
|
||||||
|
;; For debugging:
|
||||||
|
(define (inside-lock?) (eq? monitor-owner (current-thread)))
|
||||||
|
(define (any-lock?) (and monitor-owner #t))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user