summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk/wm.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib/tk/wm.rb')
-rw-r--r--ext/tk/lib/tk/wm.rb78
1 files changed, 73 insertions, 5 deletions
diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb
index f3cfb0afb1..1f432a3848 100644
--- a/ext/tk/lib/tk/wm.rb
+++ b/ext/tk/lib/tk/wm.rb
@@ -9,14 +9,18 @@ module Tk
TkCommandNames = ['wm'.freeze].freeze
+ TOPLEVEL_METHODCALL_OPTKEYS = {}
+
def aspect(*args)
if args.length == 0
list(tk_call_without_enc('wm', 'aspect', path))
else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
tk_call('wm', 'aspect', path, *args)
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['aspect'] = 'aspect'
def attributes(slot=nil,value=None)
if slot == nil
@@ -36,6 +40,7 @@ module Tk
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['attributes'] = 'attributes'
def client(name=None)
if name == None
@@ -46,15 +51,18 @@ module Tk
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['client'] = 'client'
def colormapwindows(*args)
if args.size == 0
list(tk_call_without_enc('wm', 'colormapwindows', path))
else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
tk_call_without_enc('wm', 'colormapwindows', path, *args)
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['colormapwindows'] = 'colormapwindows'
def wm_command(value=nil)
if value
@@ -65,9 +73,14 @@ module Tk
tk_call('wm', 'command', path)
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['wm_command'] = 'wm_command'
def deiconify(ex = true)
- tk_call_without_enc('wm', 'deiconify', path) if ex
+ if ex
+ tk_call_without_enc('wm', 'deiconify', path)
+ else
+ self.iconify
+ end
self
end
@@ -79,6 +92,7 @@ module Tk
tk_call_without_enc('wm', 'focusmodel', path)
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['focusmodel'] = 'focusmodel'
def frame
tk_call_without_enc('wm', 'frame', path)
@@ -92,15 +106,18 @@ module Tk
tk_call_without_enc('wm', 'geometry', path)
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['geometry'] = 'geometry'
def wm_grid(*args)
if args.size == 0
list(tk_call_without_enc('wm', 'grid', path))
else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
tk_call_without_enc('wm', 'grid', path, *args)
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['wm_grid'] = 'wm_grid'
def group(leader = nil)
if leader
@@ -110,6 +127,7 @@ module Tk
window(tk_call('wm', 'group', path))
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['group'] = 'group'
def iconbitmap(bmp=nil)
if bmp
@@ -119,21 +137,33 @@ module Tk
image_obj(tk_call_without_enc('wm', 'iconbitmap', path))
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['iconbitmap'] = 'iconbitmap'
def iconphoto(*imgs)
- # Windows only
+ if imgs.empty?
+ @wm_iconphoto = nil unless defined? @wm_iconphoto
+ return @wm_iconphoto
+ end
+
+ imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
tk_call_without_enc('wm', 'iconphoto', path, *imgs)
+ @wm_iconphoto = imgs
self
end
+ TOPLEVEL_METHODCALL_OPTKEYS['iconphoto'] = 'iconphoto'
def iconphoto_default(*imgs)
- # Windows only
+ imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
tk_call_without_enc('wm', 'iconphoto', path, '-default', *imgs)
self
end
def iconify(ex = true)
- tk_call_without_enc('wm', 'iconify', path) if ex
+ if ex
+ tk_call_without_enc('wm', 'iconify', path)
+ else
+ self.deiconify
+ end
self
end
@@ -145,6 +175,7 @@ module Tk
image_obj(tk_call_without_enc('wm', 'iconmask', path))
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['iconmask'] = 'iconmask'
def iconname(name=nil)
if name
@@ -154,15 +185,18 @@ module Tk
tk_call('wm', 'iconname', path)
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['iconname'] = 'iconname'
def iconposition(*args)
if args.size == 0
list(tk_call_without_enc('wm', 'iconposition', path))
else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
tk_call_without_enc('wm', 'iconposition', path, *args)
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['iconposition'] = 'iconposition'
def iconwindow(win = nil)
if win
@@ -173,24 +207,29 @@ module Tk
(w == '')? nil: window(w)
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['iconwindow'] = 'iconwindow'
def maxsize(*args)
if args.size == 0
list(tk_call_without_enc('wm', 'maxsize', path))
else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
tk_call_without_enc('wm', 'maxsize', path, *args)
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['maxsize'] = 'maxsize'
def minsize(*args)
if args.size == 0
list(tk_call_without_enc('wm', 'minsize', path))
else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
tk_call_without_enc('wm', 'minsize', path, *args)
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['minsize'] = 'minsize'
def overrideredirect(mode=None)
if mode == None
@@ -200,6 +239,7 @@ module Tk
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['overrideredirect'] = 'overrideredirect'
def positionfrom(who=None)
if who == None
@@ -210,6 +250,7 @@ module Tk
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['positionfrom'] = 'positionfrom'
def protocol(name=nil, cmd=nil, &b)
if cmd
@@ -226,14 +267,33 @@ module Tk
end
end
+ def protocols(kv=nil)
+ unless kv
+ ret = {}
+ self.protocol.each{|name|
+ ret[name] = self.protocol(name)
+ }
+ return ret
+ end
+
+ unless kv.kind_of?(Hash)
+ fail ArgumentError, 'expect a hash of protocol=>command'
+ end
+ kv.each{|k, v| self.protocol(k, v)}
+ self
+ end
+ TOPLEVEL_METHODCALL_OPTKEYS['protocols'] = 'protocols'
+
def resizable(*args)
if args.length == 0
list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)}
else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
tk_call_without_enc('wm', 'resizable', path, *args)
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['resizable'] = 'resizable'
def sizefrom(who=None)
if who == None
@@ -244,6 +304,7 @@ module Tk
self
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['sizefrom'] = 'sizefrom'
def stackorder
list(tk_call('wm', 'stackorder', path))
@@ -265,6 +326,7 @@ module Tk
tk_call_without_enc('wm', 'state', path)
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['state'] = 'state'
def title(str=nil)
if str
@@ -274,6 +336,7 @@ module Tk
tk_call('wm', 'title', path)
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['title'] = 'title'
def transient(master=nil)
if master
@@ -283,9 +346,14 @@ module Tk
window(tk_call_without_enc('wm', 'transient', path))
end
end
+ TOPLEVEL_METHODCALL_OPTKEYS['transient'] = 'transient'
def withdraw(ex = true)
- tk_call_without_enc('wm', 'withdraw', path) if ex
+ if ex
+ tk_call_without_enc('wm', 'withdraw', path)
+ else
+ self.deiconify
+ end
self
end
end