~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#  tkextlib/iwidgets/tabnotebook.rb
 
3
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
 
4
#
 
5
 
 
6
require 'tk'
 
7
require 'tkextlib/iwidgets.rb'
 
8
 
 
9
module Tk
 
10
  module Iwidgets
 
11
    class Tabnotebook < Tk::Itk::Widget
 
12
    end
 
13
  end
 
14
end
 
15
 
 
16
class Tk::Iwidgets::Tabnotebook
 
17
  TkCommandNames = ['::iwidgets::tabnotebook'.freeze].freeze
 
18
  WidgetClassName = 'Tabnotebook'.freeze
 
19
  WidgetClassNames[WidgetClassName] = self
 
20
 
 
21
  ####################################
 
22
 
 
23
  include TkItemConfigMethod
 
24
 
 
25
  def __item_cget_cmd(id)
 
26
    [self.path, 'pagecget', id]
 
27
  end
 
28
  private :__item_cget_cmd
 
29
 
 
30
  def __item_config_cmd(id)
 
31
    [self.path, 'pageconfigure', id]
 
32
  end
 
33
  private :__item_config_cmd
 
34
 
 
35
  def __item_strval_optkeys(id)
 
36
    super(id) << 'tabbackground' << 'tabforeground'
 
37
  end
 
38
  private :__item_strval_optkeys
 
39
 
 
40
  def tagid(tagOrId)
 
41
    if tagOrId.kind_of?(Tk::Itk::Component)
 
42
      tagOrId.name
 
43
    else
 
44
      #_get_eval_string(tagOrId)
 
45
      tagOrId
 
46
    end
 
47
  end
 
48
 
 
49
  alias pagecget itemcget
 
50
  alias pageconfigure itemconfigure
 
51
  alias pageconfiginfo itemconfiginfo
 
52
  alias current_pageconfiginfo current_itemconfiginfo
 
53
 
 
54
  private :itemcget, :itemconfigure
 
55
  private :itemconfiginfo, :current_itemconfiginfo
 
56
 
 
57
  ####################################
 
58
 
 
59
  def __boolval_optkeys
 
60
    super() << 'auto' << 'equaltabs' << 'raiseselect' << 'tabborders'
 
61
  end
 
62
  private :__boolval_optkeys
 
63
 
 
64
  def __strval_optkeys
 
65
    super() << 'backdrop' << 'tabbackground' << 'tabforeground'
 
66
  end
 
67
  private :__strval_optkeys
 
68
 
 
69
  def initialize(*args)
 
70
    super(*args)
 
71
    @tabset = self.component_widget('tabset')
 
72
  end
 
73
 
 
74
  def add(keys={})
 
75
    window(tk_call(@path, 'add', *hash_kv(keys)))
 
76
  end
 
77
 
 
78
  def child_site_list
 
79
    list(tk_call(@path, 'childsite'))
 
80
  end
 
81
 
 
82
  def child_site(idx)
 
83
    window(tk_call(@path, 'childsite', index(idx)))
 
84
  end
 
85
 
 
86
  def delete(idx1, idx2=nil)
 
87
    if idx2
 
88
      tk_call(@path, 'delete', index(idx1), index(idx2))
 
89
    else
 
90
      tk_call(@path, 'delete', index(idx1))
 
91
    end
 
92
    self
 
93
  end
 
94
 
 
95
  def index(idx)
 
96
    #number(tk_call(@path, 'index', tagid(idx)))
 
97
    @tabset.index(tagid(idx))
 
98
  end
 
99
 
 
100
  def insert(idx, keys={})
 
101
    window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
 
102
  end
 
103
 
 
104
  def next
 
105
    tk_call(@path, 'next')
 
106
    self
 
107
  end
 
108
 
 
109
  def prev
 
110
    tk_call(@path, 'prev')
 
111
    self
 
112
  end
 
113
 
 
114
  def select(idx)
 
115
    tk_call(@path, 'select', index(idx))
 
116
    self
 
117
  end
 
118
 
 
119
  def scrollcommand(cmd=Proc.new)
 
120
    configure_cmd 'scrollcommand', cmd
 
121
    self
 
122
  end
 
123
  alias xscrollcommand scrollcommand
 
124
  alias yscrollcommand scrollcommand
 
125
 
 
126
  def xscrollbar(bar=nil)
 
127
    if bar
 
128
      @scrollbar = bar
 
129
      @scrollbar.orient 'horizontal'
 
130
      self.scrollcommand {|*arg| @scrollbar.set(*arg)}
 
131
      @scrollbar.command {|*arg| self.xview(*arg)}
 
132
      Tk.update  # avoid scrollbar trouble
 
133
    end
 
134
    @scrollbar
 
135
  end
 
136
  def yscrollbar(bar=nil)
 
137
    if bar
 
138
      @scrollbar = bar
 
139
      @scrollbar.orient 'vertical'
 
140
      self.scrollcommand {|*arg| @scrollbar.set(*arg)}
 
141
      @scrollbar.command {|*arg| self.yview(*arg)}
 
142
      Tk.update  # avoid scrollbar trouble
 
143
    end
 
144
    @scrollbar
 
145
  end
 
146
  alias scrollbar yscrollbar
 
147
 
 
148
  def view(*index)
 
149
    if index.size == 0
 
150
      window(tk_send_without_enc('view'))
 
151
    else
 
152
      tk_send_without_enc('view', *index)
 
153
      self
 
154
    end
 
155
  end
 
156
  alias xview view
 
157
  alias yview view
 
158
 
 
159
  def view_moveto(*index)
 
160
    view('moveto', *index)
 
161
  end
 
162
  alias xview_moveto view_moveto
 
163
  alias yview_moveto view_moveto
 
164
  def view_scroll(*index)
 
165
    view('scroll', *index)
 
166
  end
 
167
  alias xview_scroll view_scroll
 
168
  alias yview_scroll view_scroll
 
169
end