2 # tkextlib/iwidgets/tabnotebook.rb
3 # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
7 require 'tkextlib/iwidgets.rb'
11 class Tabnotebook < Tk::Itk::Widget
16 class Tk::Iwidgets::Tabnotebook
17 TkCommandNames = ['::iwidgets::tabnotebook'.freeze].freeze
18 WidgetClassName = 'Tabnotebook'.freeze
19 WidgetClassNames[WidgetClassName] = self
21 ####################################
23 include TkItemConfigMethod
25 def __item_cget_cmd(id)
26 [self.path, 'pagecget', id]
28 private :__item_cget_cmd
30 def __item_config_cmd(id)
31 [self.path, 'pageconfigure', id]
33 private :__item_config_cmd
35 def __item_strval_optkeys(id)
36 super(id) << 'tabbackground' << 'tabforeground'
38 private :__item_strval_optkeys
41 if tagOrId.kind_of?(Tk::Itk::Component)
44 #_get_eval_string(tagOrId)
49 alias pagecget itemcget
50 alias pagecget_strict itemcget_strict
51 alias pageconfigure itemconfigure
52 alias pageconfiginfo itemconfiginfo
53 alias current_pageconfiginfo current_itemconfiginfo
55 private :itemcget, :itemcget_strict
56 private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
58 ####################################
61 super() << 'auto' << 'equaltabs' << 'raiseselect' << 'tabborders'
63 private :__boolval_optkeys
66 super() << 'backdrop' << 'tabbackground' << 'tabforeground'
68 private :__strval_optkeys
72 @tabset = self.component_widget('tabset')
76 window(tk_call(@path, 'add', *hash_kv(keys)))
80 list(tk_call(@path, 'childsite'))
84 window(tk_call(@path, 'childsite', index(idx)))
87 def delete(idx1, idx2=nil)
89 tk_call(@path, 'delete', index(idx1), index(idx2))
91 tk_call(@path, 'delete', index(idx1))
97 #number(tk_call(@path, 'index', tagid(idx)))
98 @tabset.index(tagid(idx))
101 def insert(idx, keys={})
102 window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
106 tk_call(@path, 'next')
111 tk_call(@path, 'prev')
116 tk_call(@path, 'select', index(idx))
121 @tabset.show_tab(idx)
125 def scrollcommand(cmd=Proc.new)
126 configure_cmd 'scrollcommand', cmd
129 alias xscrollcommand scrollcommand
130 alias yscrollcommand scrollcommand
132 def xscrollbar(bar=nil)
135 @scrollbar.orient 'horizontal'
136 self.scrollcommand {|*arg| @scrollbar.set(*arg)}
137 @scrollbar.command {|*arg| self.xview(*arg)}
138 Tk.update # avoid scrollbar trouble
142 def yscrollbar(bar=nil)
145 @scrollbar.orient 'vertical'
146 self.scrollcommand {|*arg| @scrollbar.set(*arg)}
147 @scrollbar.command {|*arg| self.yview(*arg)}
148 Tk.update # avoid scrollbar trouble
152 alias scrollbar yscrollbar
156 idx = num_or_str(tk_send_without_enc('view'))
157 if idx.kind_of?(Fixnum) && idx < 0
163 tk_send_without_enc('view', *index)
170 def view_moveto(*index)
171 view('moveto', *index)
173 alias xview_moveto view_moveto
174 alias yview_moveto view_moveto
175 def view_scroll(index, what='pages')
176 view('scroll', index, what)
178 alias xview_scroll view_scroll
179 alias yview_scroll view_scroll