summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk/ttk_selector.rb
blob: cc9e9928cba37093d2c33eefdc34ed03d6fefcf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
#  ttk_selector
#
######################################
#  toplevel classes/modules
module Tk
  @TOPLEVEL_ALIAS_TABLE[:Ttk] = {
    :TkButton       => 'tkextlib/tile/tbutton',

    :TkCheckbutton  => 'tkextlib/tile/tcheckbutton',
    :TkCheckButton  => 'tkextlib/tile/tcheckbutton',

    # :TkDialog       => 'tkextlib/tile/dialog',

    :TkEntry        => 'tkextlib/tile/tentry',

    :TkCombobox     => 'tkextlib/tile/tcombobox',

    :TkFrame        => 'tkextlib/tile/tframe',

    :TkLabel        => 'tkextlib/tile/tlabel',

    :TkLabelframe   => 'tkextlib/tile/tlabelframe',
    :TkLabelFrame   => 'tkextlib/tile/tlabelframe',

    :TkMenubutton   => 'tkextlib/tile/tmenubutton',
    :TkMenuButton   => 'tkextlib/tile/tmenubutton',

    :TkNotebook     => 'tkextlib/tile/tnotebook',

    # :TkPaned        => 'tkextlib/tile/tpaned',
    :TkPanedwindow  => 'tkextlib/tile/tpaned',
    :TkPanedWindow  => 'tkextlib/tile/tpaned',

    :TkProgressbar  => 'tkextlib/tile/tprogressbar',

    :TkRadiobutton  => 'tkextlib/tile/tradiobutton',
    :TkRadioButton  => 'tkextlib/tile/tradiobutton',

    :TkScale        => 'tkextlib/tile/tscale',
    # :TkProgress     => 'tkextlib/tile/tscale',

    :TkScrollbar    => 'tkextlib/tile/tscrollbar',
    :TkXScrollbar   => 'tkextlib/tile/tscrollbar',
    :TkYScrollbar   => 'tkextlib/tile/tscrollbar',

    :TkSeparator    => 'tkextlib/tile/tseparator',

    :TkSizeGrip     => 'tkextlib/tile/sizegrip',
    :TkSizegrip     => 'tkextlib/tile/sizegrip',

    # :TkSquare       => 'tkextlib/tile/tsquare',

    :TkTreeview     => 'tkextlib/tile/treeview',
  }

  # @TOPLEVEL_ALIAS_TABLE[:Tile] = @TOPLEVEL_ALIAS_TABLE[:Ttk]
  Tk.__create_widget_set__(:Tile, :Ttk)

  ############################################
  #  depend on the version of Tcl/Tk
  major, minor, type, patchlevel = TclTkLib.get_version

  #  ttk::spinbox is supported on Tcl/Tk8.6b1 or later
  if ([major,minor,type,patchlevel] <=>
        [8,6,TclTkLib::RELEASE_TYPE::BETA,1]) >= 0
    @TOPLEVEL_ALIAS_TABLE[:Ttk].update(
      :TkSpinbox => 'tkextlib/tile/tspinbox'
    )
  end

  ################################################
  # register some Ttk widgets as default
  # (Ttk is a standard library on Tcl/Tk8.5+)
  @TOPLEVEL_ALIAS_TABLE[:Ttk].each{|sym, file|
    #unless Tk::TOPLEVEL_ALIASES.autoload?(sym) || Tk::TOPLEVEL_ALIASES.const_defined?(sym)
    #   @TOPLEVEL_ALIAS_OWNER[sym] = :Ttk
    #   Tk::TOPLEVEL_ALIASES.autoload(sym, file)
    #end
    Tk.__regist_toplevel_aliases__(:Ttk, file, sym)
  }

  ################################################

  # @TOPLEVEL_ALIAS_SETUP_PROC[:Tile] =
  #   @TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod|
  #   unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
  #     Object.autoload :Ttk, 'tkextlib/tile'
  #     Tk.autoload :Tile, 'tkextlib/tile'
  #   end
  # }
  Tk.__toplevel_alias_setup_proc__(:Ttk, :Tile){|mod|
    unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
      Object.autoload :Ttk, 'tkextlib/tile'
      Tk.autoload :Tile, 'tkextlib/tile'
    end
  }
end