From: Axel [email protected]
Subject: TK: Get the “usable” screensize"?
Date: Tue, 2 Feb 2010 03:55:24 +0900
Message-ID:
[email protected]
I found Total Window Geometry which points into the
same direction, but I cannot use it with success (it’s TCL).
FYI, Ruby/Tk can use Tcl scripts.
For example,
Tk.ip_eval <<EOS
proc totalGeometry {{w .}} {
set geom [wm geometry $w]
regexp – {([0-9]+)x([0-9]+)+([0-9]+)+([0-9]+)} $geom →
width height decorationLeft decorationTop
set contentsTop [winfo rooty $w]
set contentsLeft [winfo rootx $w]
# Measure left edge, and assume all edges except top are the
# same thickness
set decorationThickness [expr {$contentsLeft -
$decorationLeft}]
# Find titlebar and menubar thickness
set menubarThickness [expr {$contentsTop - $decorationTop}]
incr width [expr {2 * $decorationThickness}]
incr height $decorationThickness
incr height $menubarThickness
return [list $width $height $decorationLeft $decorationTop]
}
EOS
Tk.ip_eval <<EOS
proc taskbar {{w .taskBarSize}} {
catch {destroy $w}
toplevel $w
wm state $w zoomed
update
set val [expr {[winfo screenheight $w]-[winfo height $w]}]
destroy $w
return $val;
}
EOS
Tk.tk_call(“totalGeometry”) #=> e.g. “220 72 0 0”
TkComm.simplelist(Tk.tk_call(“totalGeometry”)) #=> e.g. [“220”, “72”,
“0”, “0”]
TkComm.list(Tk.tk_call(“totalGeometry”)) #=> e.g. [220, 72, 0, 0]
TkComm.tk_tcl2ruby(Tk.tk_call(“totalGeometry”)) #=> e.g. [220, 72, 0, 0]
Tk.tk_call_to_simplelist(“totalGeometry”)) #=> e.g. [“220”, “72”, “0”,
“0”]
Tk.tk_call_to_list(“totalGeometry”)) #=> e.g. [220, 72, 0, 0]
top = TkToplevel.new
Tk.tk_call(“totalGeometry”, top) #=> e.g. “230 104 0 0”
Tk.tk_call(“taskbar”) #=> e.g. “47”
TkComm.number(Tk.tk_call(“taskbar”)) #=> e.g. 47
TkComm.tk_tcl2ruby(Tk.tk_call(“taskbar”)) #=> e.g. 47
Also, please see an example ext/tk/sample/tktree.rb and tktree.tcl on
Ruby’s source tree.