File: tk/panedwindow.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Tk
  class: PanedWindow#6
inherits from
  TkWindow   
has properties
constant: TkCommandNames #7
constant: WidgetClassName #8
method: add / 1 #19
method: forget / 2 #37
alias: del forget #43
alias: delete forget #44
alias: remove forget #45
method: identify / 2 #47
method: proxy_coord #51
method: proxy_forget #54
method: proxy_place / 2 #58
method: sash_coord / 1 #63
method: sash_dragto / 3 #66
method: sash_mark / 3 #70
method: sash_place / 3 #74
method: panecget_strict / 2 #79
method: panecget / 2 #84
method: paneconfigure / 3 #106
alias: pane_config paneconfigure #124
method: paneconfiginfo / 2 #126
alias: pane_configinfo paneconfiginfo #224
method: current_paneconfiginfo / 2 #226
alias: current_pane_configinfo current_paneconfiginfo #247
method: panes #249

Class Hierarchy

Object ( Builtin-Module )
TkKernel
TkObject
TkWindow
  PanedWindow ( Tk ) #6

Code

   1  #
   2  # tk/panedwindow.rb : treat panedwindow
   3  #
   4  require 'tk'
   5 
   6  class Tk::PanedWindow<TkWindow
   7    TkCommandNames = ['panedwindow'.freeze].freeze
   8    WidgetClassName = 'Panedwindow'.freeze
   9    WidgetClassNames[WidgetClassName] = self
  10    #def create_self(keys)
  11    #  if keys and keys != None
  12    #    tk_call_without_enc('panedwindow', @path, *hash_kv(keys, true))
  13    #  else
  14    #    tk_call_without_enc('panedwindow', @path)
  15    #  end
  16    #end
  17    #private :create_self
  18 
  19    def add(*args)
  20      keys = args.pop
  21      fail ArgumentError, "no window in arguments" unless keys
  22      if keys && keys.kind_of?(Hash)
  23        fail ArgumentError, "no window in arguments" if args == []
  24        # args = args.collect{|w| (w.kind_of?(TkObject))? w.epath: w }
  25        args = args.collect{|w| _epath(w) }
  26        #args.push(hash_kv(keys))
  27        args.concat(hash_kv(keys))
  28      else
  29        args.push(keys) if keys
  30        # args = args.collect{|w| (w.kind_of?(TkObject))? w.epath: w }
  31        args = args.collect{|w| _epath(w) }
  32      end
  33      tk_send_without_enc('add', *args)
  34      self
  35    end
  36 
  37    def forget(win, *wins)
  38      wins.unshift(win)
  39      # tk_send_without_enc('forget', *((w.kind_of?(TkObject))? w.epath: w))
  40      tk_send_without_enc('forget', *(wins.collect{|w| _epath(w)}))
  41      self
  42    end
  43    alias del forget
  44    alias delete forget
  45    alias remove forget
  46 
  47    def identify(x, y)
  48      list(tk_send_without_enc('identify', x, y))
  49    end
  50 
  51    def proxy_coord
  52      list(tk_send_without_enc('proxy', 'coord'))
  53    end
  54    def proxy_forget
  55      tk_send_without_enc('proxy', 'forget')
  56      self
  57    end
  58    def proxy_place(x, y)
  59      tk_send_without_enc('proxy', 'place', x, y)
  60      self
  61    end
  62 
  63    def sash_coord(index)
  64      list(tk_send('sash', 'coord', index))
  65    end
  66    def sash_dragto(index, x, y)
  67      tk_send('sash', 'dragto', index, x, y)
  68      self
  69    end
  70    def sash_mark(index, x, y)
  71      tk_send('sash', 'mark', index, x, y)
  72      self
  73    end
  74    def sash_place(index, x, y)
  75      tk_send('sash', 'place', index, x, y)
  76      self
  77    end
  78 
  79    def panecget_strict(win, key)
  80      # win = win.epath if win.kind_of?(TkObject)
  81      win = _epath(win)
  82      tk_tcl2ruby(tk_send_without_enc('panecget', win, "-#{key}"))
  83    end
  84    def panecget(win, key)
  85      unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
  86        panecget_strict(win, key)
  87      else
  88        begin
  89          panecget_strict(win, key)
  90        rescue => e
  91          begin
  92            if current_paneconfiginfo(win).has_key?(option.to_s)
  93              # not tag error & option is known -> error on known option
  94              fail e
  95            else
  96              # not tag error & option is unknown
  97              nil
  98            end
  99          rescue
 100            fail e  # tag error
 101          end
 102        end
 103      end
 104    end
 105 
 106    def paneconfigure(win, key, value=nil)
 107      # win = win.epath if win.kind_of?(TkObject)
 108      win = _epath(win)
 109      if key.kind_of? Hash
 110        params = []
 111        key.each{|k, v|
 112          params.push("-#{k}")
 113          # params.push((v.kind_of?(TkObject))? v.epath: v)
 114          params.push(_epath(v))
 115        }
 116        tk_send_without_enc('paneconfigure', win, *params)
 117      else
 118        # value = value.epath if value.kind_of?(TkObject)
 119        value = _epath(value)
 120        tk_send_without_enc('paneconfigure', win, "-#{key}", value)
 121      end
 122      self
 123    end
 124    alias pane_config paneconfigure
 125 
 126    def paneconfiginfo(win, key=nil)
 127      if TkComm::GET_CONFIGINFO_AS_ARRAY
 128        # win = win.epath if win.kind_of?(TkObject)
 129        win = _epath(win)
 130        if key
 131          #conf = tk_split_list(tk_send_without_enc('paneconfigure', 
 132          #                                         win, "-#{key}"))
 133          conf = tk_split_list(tk_send_without_enc('paneconfigure', 
 134                                                   win, "-#{key}"), 
 135                               false, true)
 136          conf[0] = conf[0][1..-1]
 137          if conf[0] == 'hide'
 138            conf[3] = bool(conf[3]) unless conf[3].empty?
 139            conf[4] = bool(conf[4]) unless conf[4].empty?
 140          end
 141          conf
 142        else
 143          #tk_split_simplelist(tk_send_without_enc('paneconfigure', 
 144          #                                        win)).collect{|conflist|
 145          #  conf = tk_split_simplelist(conflist)
 146          tk_split_simplelist(tk_send_without_enc('paneconfigure', win), 
 147                              false, false).collect{|conflist|
 148            conf = tk_split_simplelist(conflist, false, true)
 149            conf[0] = conf[0][1..-1]
 150            if conf[3]
 151              if conf[0] == 'hide'
 152                conf[3] = bool(conf[3]) unless conf[3].empty?
 153              elsif conf[3].index('{')
 154                conf[3] = tk_split_list(conf[3]) 
 155              else
 156                conf[3] = tk_tcl2ruby(conf[3]) 
 157              end
 158            end
 159            if conf[4]
 160              if conf[0] == 'hide'
 161                conf[4] = bool(conf[4]) unless conf[4].empty?
 162              elsif conf[4].index('{')
 163                conf[4] = tk_split_list(conf[4]) 
 164              else
 165                conf[4] = tk_tcl2ruby(conf[4]) 
 166              end
 167            end
 168            conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
 169            conf
 170          }
 171        end
 172      else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
 173        # win = win.epath if win.kind_of?(TkObject)
 174        win = _epath(win)
 175        if key
 176          #conf = tk_split_list(tk_send_without_enc('paneconfigure', 
 177          #                                         win, "-#{key}"))
 178          conf = tk_split_list(tk_send_without_enc('paneconfigure', 
 179                                                   win, "-#{key}"), 
 180                               false, true)
 181          key = conf.shift[1..-1]
 182          if key == 'hide'
 183            conf[2] = bool(conf[2]) unless conf[2].empty?
 184            conf[3] = bool(conf[3]) unless conf[3].empty?
 185          end
 186          { key => conf }
 187        else
 188          ret = {}
 189          #tk_split_simplelist(tk_send_without_enc('paneconfigure', 
 190          #                                        win)).each{|conflist|
 191          #  conf = tk_split_simplelist(conflist)
 192          tk_split_simplelist(tk_send_without_enc('paneconfigure', win), 
 193                              false, false).each{|conflist|
 194            conf = tk_split_simplelist(conflist, false, true)
 195            key = conf.shift[1..-1]
 196            if key
 197              if key == 'hide'
 198                conf[2] = bool(conf[2]) unless conf[2].empty?
 199              elsif conf[2].index('{')
 200                conf[2] = tk_split_list(conf[2]) 
 201              else
 202                conf[2] = tk_tcl2ruby(conf[2]) 
 203              end
 204            end
 205            if conf[3]
 206              if key == 'hide'
 207                conf[3] = bool(conf[3]) unless conf[3].empty?
 208              elsif conf[3].index('{')
 209                conf[3] = tk_split_list(conf[3]) 
 210              else
 211                conf[3] = tk_tcl2ruby(conf[3]) 
 212              end
 213            end
 214            if conf.size == 1
 215              ret[key] = conf[0][1..-1]  # alias info
 216            else
 217              ret[key] = conf
 218            end
 219          }
 220          ret
 221        end
 222      end
 223    end
 224    alias pane_configinfo paneconfiginfo
 225 
 226    def current_paneconfiginfo(win, key=nil)
 227      if TkComm::GET_CONFIGINFO_AS_ARRAY
 228        if key
 229          conf = paneconfiginfo(win, key)
 230          {conf[0] => conf[4]}
 231        else
 232          ret = {}
 233          paneconfiginfo(win).each{|conf|
 234            ret[conf[0]] = conf[4] if conf.size > 2
 235          }
 236          ret
 237        end
 238      else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
 239        ret = {}
 240        paneconfiginfo(win, key).each{|k, conf|
 241          ret[k] = conf[-1] if conf.kind_of?(Array)
 242        }
 243        ret
 244      end
 245    end
 246 
 247    alias current_pane_configinfo current_paneconfiginfo
 248 
 249    def panes
 250      list(tk_send_without_enc('panes'))
 251    end
 252  end
 253 
 254  Tk::Panedwindow = Tk::PanedWindow
 255  #TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow
 256  #TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow
 257  Tk.__set_toplevel_aliases__(:Tk, Tk::PanedWindow, 
 258                              :TkPanedWindow, :TkPanedwindow)