URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
578 |
markom |
# center.tcl - Center a window on the screen or over another window
|
2 |
|
|
# Copyright (C) 1997, 1998, 2001 Red Hat, Inc.
|
3 |
|
|
# Written by Tom Tromey <tromey@cygnus.com>.
|
4 |
|
|
|
5 |
|
|
# Call this after the TOPLEVEL has been filled in, but before it has
|
6 |
|
|
# been mapped. This proc will center the toplevel on the screen or
|
7 |
|
|
# over another window.
|
8 |
|
|
proc center_window {top args} {
|
9 |
|
|
parse_args {{over ""}}
|
10 |
|
|
|
11 |
|
|
update idletasks
|
12 |
|
|
if {$over != ""} {
|
13 |
|
|
set cx [expr {int ([winfo rootx $over] + [winfo width $over] / 2)}]
|
14 |
|
|
set cy [expr {int ([winfo rooty $over] + [winfo height $over] / 2)}]
|
15 |
|
|
set x [expr {$cx - int ([winfo reqwidth $top] / 2)}]
|
16 |
|
|
set y [expr {$cy - int ([winfo reqheight $top] / 2)}]
|
17 |
|
|
} else {
|
18 |
|
|
set x [expr {int (([winfo screenwidth $top] - [winfo reqwidth $top]) / 2)}]
|
19 |
|
|
set y [expr {int (([winfo screenheight $top] - [winfo reqheight $top]) / 2)}]
|
20 |
|
|
}
|
21 |
|
|
wm geometry $top +${x}+${y}
|
22 |
|
|
wm positionfrom $top user
|
23 |
|
|
|
24 |
|
|
# We run this update here because Tk updates toplevel geometry
|
25 |
|
|
# (position) info in an idle handler on Windows, but doesn't force
|
26 |
|
|
# the handler to run before mapping the window.
|
27 |
|
|
update idletasks
|
28 |
|
|
}
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.