center dialogs that have no location

svn: r3183
This commit is contained in:
Matthew Flatt 2006-06-02 15:10:47 +00:00
parent c127c5f422
commit c5c852b88e
4 changed files with 20 additions and 15 deletions

View File

@ -208,7 +208,7 @@
(class100*/kw basic-top-level-window% () (class100*/kw basic-top-level-window% ()
[(label [parent #f] [width #f] [height #f] [x #f] [y #f] [style null]) [(label [parent #f] [width #f] [height #f] [x #f] [y #f] [style null])
top-level-window%-keywords] top-level-window%-keywords]
(inherit on-traverse-char on-system-menu-char) (inherit on-traverse-char on-system-menu-char center)
(sequence (sequence
(let ([cwho '(constructor dialog)]) (let ([cwho '(constructor dialog)])
(check-label-string cwho label) (check-label-string cwho label)
@ -228,7 +228,7 @@
(super-init (lambda (finish) (super-init (lambda (finish)
(set! wx (finish (make-object wx-dialog% this this (set! wx (finish (make-object wx-dialog% this this
(and parent (mred->wx parent)) label #t (and parent (mred->wx parent)) label #t
(or x -1) (or y -1) (or width 0) (or height 0) (or x -11111) (or y -11111) (or width 0) (or height 0)
style) style)
#f)) #f))
wx) wx)

View File

@ -337,18 +337,20 @@
(force-redraw)) (force-redraw))
(when (and on? use-default-position?) (when (and on? use-default-position?)
(set! use-default-position? #f) (set! use-default-position? #f)
(let*-values ([(w) (get-width)] (if dlg?
[(h) (get-height)] (center 'both)
[(sw sh) (get-display-size)] (let*-values ([(w) (get-width)]
[(x x-reset?) (if (< (+ top-x w) sw) [(h) (get-height)]
(values top-x #f) [(sw sh) (get-display-size)]
(values (max 0 (- sw w 10)) #t))] [(x x-reset?) (if (< (+ top-x w) sw)
[(y y-reset?) (if (< (+ top-y h) sh) (values top-x #f)
(values top-y #f) (values (max 0 (- sw w 10)) #t))]
(values (max 0 (- sh h 20)) #t))]) [(y y-reset?) (if (< (+ top-y h) sh)
(move x y) (values top-y #f)
(set! top-x (if x-reset? init-top-x (+ top-x 10))) (values (max 0 (- sh h 20)) #t))])
(set! top-y (if y-reset? init-top-y (+ top-y 20))))) (move x y)
(set! top-x (if x-reset? init-top-x (+ top-x 10)))
(set! top-y (if y-reset? init-top-y (+ top-y 20))))))
(if on? (if on?
(hash-table-put! top-level-windows this #t) (hash-table-put! top-level-windows this #t)
(hash-table-remove! top-level-windows this)) (hash-table-remove! top-level-windows this))

View File

@ -1,3 +1,6 @@
Version 301.16
When no location is given for a dialog%, it is centered when
shown
Version 301.8 Version 301.8
Added 'no-sheet dialog% style Added 'no-sheet dialog% style

View File

@ -61,7 +61,7 @@ void wxbDialogBox::Centre(int direction)
int width, height, x, y; int width, height, x, y;
wxFrame *frame; wxFrame *frame;
if (direction & wxCENTER_FRAME) { if (1 /* direction & wxCENTER_FRAME */) {
frame = (wxFrame*)GetParent(); frame = (wxFrame*)GetParent();
if (frame) { if (frame) {
frame->GetPosition(&x_offset, &y_offset); frame->GetPosition(&x_offset, &y_offset);