alignment of cells
This commit is contained in:
38
main.rkt
38
main.rkt
@@ -19,6 +19,12 @@
|
|||||||
(let ((new-pane (new horizontal-pane% [parent this]
|
(let ((new-pane (new horizontal-pane% [parent this]
|
||||||
[spacing spacing] [horiz-margin horiz-margin] [vert-margin (round (/ spacing 2))]
|
[spacing spacing] [horiz-margin horiz-margin] [vert-margin (round (/ spacing 2))]
|
||||||
[stretchable-height #f])))
|
[stretchable-height #f])))
|
||||||
|
(letrec ((adder (lambda (col)
|
||||||
|
(when (< col columns)
|
||||||
|
(new horizontal-pane% [parent new-pane] [stretchable-width #t]
|
||||||
|
[alignment (list (cell-alignment* col) 'center)]))
|
||||||
|
(adder (+ col 1)))))
|
||||||
|
(adder 0))
|
||||||
(set! creating-row #f)
|
(set! creating-row #f)
|
||||||
new-pane)
|
new-pane)
|
||||||
)
|
)
|
||||||
@@ -36,13 +42,18 @@
|
|||||||
(vector-set! hpanes i p))
|
(vector-set! hpanes i p))
|
||||||
p))
|
p))
|
||||||
|
|
||||||
|
(define/private (cell* c r)
|
||||||
|
(let* ((row (get-row* r))
|
||||||
|
(cells (send row get-children)))
|
||||||
|
(list-ref cells c)))
|
||||||
|
|
||||||
(define/private (child* c r)
|
(define/private (child* c r)
|
||||||
(let* ((hpane (vector-ref hpanes r))
|
(let* ((cell (cell* c r))
|
||||||
(children (send hpane get-children))
|
(children (send cell get-children))
|
||||||
(child (if (>= c (length children)) #f (list-ref children c)))
|
(child (if (null? children) #f (car children)))
|
||||||
)
|
)
|
||||||
child))
|
child))
|
||||||
|
|
||||||
(define/private (max-width* c r w)
|
(define/private (max-width* c r w)
|
||||||
(if (< r (vector-length hpanes))
|
(if (< r (vector-length hpanes))
|
||||||
(let* ((child (child* c r))
|
(let* ((child (child* c r))
|
||||||
@@ -78,25 +89,30 @@
|
|||||||
|
|
||||||
;; Internal data
|
;; Internal data
|
||||||
(define column-min-widths (make-vector columns 0))
|
(define column-min-widths (make-vector columns 0))
|
||||||
|
(define column-aligns (make-vector columns 'left))
|
||||||
|
|
||||||
;; Public methods
|
;; Public methods
|
||||||
(define/public (column-min-width c . w)
|
(define/public (column-min-width c . w)
|
||||||
(unless (null? w)
|
(unless (null? w)
|
||||||
(vector-set! column-min-widths c (car w)))
|
(vector-set! column-min-widths c (car w)))
|
||||||
(vector-ref column-min-widths c))
|
(vector-ref column-min-widths c))
|
||||||
|
|
||||||
|
(define/public (column-align c . a)
|
||||||
|
(unless (null? a)
|
||||||
|
(vector-set! column-aligns c (car a)))
|
||||||
|
(vector-reff column-aligns c))
|
||||||
|
|
||||||
;; Overridden methods
|
;; Overridden methods
|
||||||
(define/override (after-new-child child)
|
(define/override (after-new-child child)
|
||||||
(super after-new-child child)
|
(super after-new-child child)
|
||||||
(when (eq? creating-row #f)
|
(when (eq? creating-row #f)
|
||||||
(let ((hpane (get-row* current-row)))
|
(let ((cell (get-cell* current-col current-row)))
|
||||||
(send child reparent hpane)
|
(send child reparent cell))
|
||||||
(set! current-col (+ current-col 1))
|
(set! current-col (+ current-col 1))
|
||||||
(when (>= current-col columns)
|
(when (>= current-col columns)
|
||||||
(set! current-row (+ current-row 1))
|
(set! current-row (+ current-row 1))
|
||||||
(set! current-col 0))
|
(set! current-col 0))
|
||||||
)))
|
))
|
||||||
|
|
||||||
(define/override (place-children info width height)
|
(define/override (place-children info width height)
|
||||||
(let ((r (super place-children info width height)))
|
(let ((r (super place-children info width height)))
|
||||||
|
|||||||
Reference in New Issue
Block a user