ok
This commit is contained in:
24
main.rkt
24
main.rkt
@@ -19,19 +19,19 @@
|
||||
(lambda (w h) w))))
|
||||
;(printf "label: ~a, max-w: ~a, w: ~a\n" l w ext)
|
||||
(if (or (< w 10) (<= ext w) (string=? l ""))
|
||||
l
|
||||
(if (eq? ellipsis 'right)
|
||||
(string-append (str:string-drop-right l 3) "...")
|
||||
(string-append "..." (str:string-drop l 3)))
|
||||
(let* ((factor (/ w ext))
|
||||
(strl (string-length l))
|
||||
(n-strl (round (* strl factor)))
|
||||
(drop (- strl n-strl)))
|
||||
(when (= drop 0)
|
||||
(set! drop 1))
|
||||
(if (eq? ellipsis 'right)
|
||||
(if (eq? ellipsis 'left)
|
||||
(let ((nl (str:string-drop l drop)))
|
||||
;(printf "new-try ~a\n" nl)
|
||||
(ellipsize w (str:string-drop l drop)))
|
||||
(let ((nl (str:string-drop-right l drop)))
|
||||
;(printf "new-try ~a\n" nl)
|
||||
(ellipsize w (str:string-drop-right l drop))))))))
|
||||
|
||||
(define/override (set-label l . resize)
|
||||
@@ -60,11 +60,11 @@
|
||||
my_label)
|
||||
))
|
||||
|
||||
;(define win (new frame% [label "Hi there!"]))
|
||||
;(define hp1 (new horizontal-pane% [parent win]))
|
||||
;(define btn1 (new button% [label "Longer 1"] [parent hp1] [callback (lambda (b e) (send lbl1 set-label "This is a very long text, yes a longer text than we initial put"))]))
|
||||
;(define lbl1 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp1] [ellipsis 'right]))
|
||||
;(define hp2 (new horizontal-pane% [parent win]))
|
||||
;(define btn2 (new button% [label "Longer 2"] [parent hp2] [callback (lambda (b e) (send lbl2 set-label "This is a very long second text, yes a longer text than we initial put"))]))
|
||||
;(define lbl2 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp2] [ellipsis 'left]))
|
||||
;(send win show #t)
|
||||
(define win (new frame% [label "Hi there!"]))
|
||||
(define hp1 (new horizontal-pane% [parent win]))
|
||||
(define btn1 (new button% [label "Longer 1"] [parent hp1] [callback (lambda (b e) (send lbl1 set-label "This is a very long text, yes a longer text than we initial put"))]))
|
||||
(define lbl1 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp1] [ellipsis 'right]))
|
||||
(define hp2 (new horizontal-pane% [parent win]))
|
||||
(define btn2 (new button% [label "Longer 2"] [parent hp2] [callback (lambda (b e) (send lbl2 set-label "This is a very long second text, yes a longer text than we initial put"))]))
|
||||
(define lbl2 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp2] [ellipsis 'left]))
|
||||
(send win show #t)
|
||||
|
||||
Reference in New Issue
Block a user