summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc.rb
blob: 72a7c6901de4cd4819e7f441aebd77e9d2476090 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#
# kroc.rb
#
# based on:
#   >> kroc.tcl - Copyright (C) 2004 David Zolli <kroc@kroc.tk>
#

imgdir = File.join(File.dirname(__FILE__), 'kroc', 'kroc')
$images = Tk::Tile.load_images(imgdir, '*.gif')

if TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0
  $TNotebook_Tab = Tk::Tile::TNotebook.style('Tab')
else
  $TNotebook_Tab = 'Tab.TNotebook'
end

def kroc_rb_settings
  # Tk::Tile::Style.default(TkRoot, :background=>'#FCB64F',
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(Tk.root, :background=>'#FCB64F',
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default('.', :background=>'#FCB64F',
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(nil, :background=>'#FCB64F',
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  Tk::Tile::Style.default(:background=>'#FCB64F', :troughcolor=>'#F8C278',
                          :borderwidth=>1)
  # Tk::Tile::Style.default(TkRoot, :font=>Tk::Tile::Font::Default,
  #                         :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(Tk.root, :font=>Tk::Tile::Font::Default,
  #                         :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default('.', :font=>Tk::Tile::Font::Default,
  #                         :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(nil, :font=>Tk::Tile::Font::Default,
  #                         :borderwidth=>1)
  #   or
  Tk::Tile::Style.default(:font=>Tk::Tile::Font::Default, :borderwidth=>1)

  # Tk::Tile::Style.map(TkRoot, :background=>[:active, '#694418'])
  #   or
  # Tk::Tile::Style.map(Tk.root, :background=>[:active, '#694418'])
  #   or
  # Tk::Tile::Style.map('.', :background=>[:active, '#694418'])
  #   or
  # Tk::Tile::Style.map(nil, :background=>[:active, '#694418'])
  #   or
  Tk::Tile::Style.map(:background=>[:active, '#694418'])
  Tk::Tile::Style.map(:foreground=>[:disabled, '#B2B2B2', :active, '#FFE7CB'])

  # Tk::Tile::Style.default('TButton', :padding=>[10,4])
  Tk::Tile::Style.default(Tk::Tile::TButton, :padding=>[10,4])

  # Tk::Tile::Style.default('TNotebook.Tab',
  Tk::Tile::Style.default($TNotebook_Tab,
                          :padding=>[10, 3], :font=>Tk::Tile::Font::Default)
  # Tk::Tile::Style.map('TNotebook.Tab',
  Tk::Tile::Style.map($TNotebook_Tab,
                      :background=>[:selected, '#FCB64F', '', '#FFE6BA'],
                      :foreground=>['', 'black'],
                      :padding=>[:selected, [10, 6, 10, 3]])

  # Tk::Tile::Style.map('TScrollbar',
  Tk::Tile::Style.map(Tk::Tile::TScrollbar,
                      :background=>[:pressed, '#694418'],
                      :arrowcolor=>[:pressed, '#FEF7CB'],
                      :relief=>[:pressed, :sunken])

  # Tk::Tile::Style.layout('Vertical.TScrollbar',
  Tk::Tile::Style.layout(Tk::Tile.style('Vertical', Tk::Tile::TScrollbar),
                         ['Scrollbar.trough', {:children=>[
                             'Scrollbar.uparrow',   {:side=>:top},
                             'Scrollbar.downarrow', {:side=>:bottom},
                             'Scrollbar.uparrow',   {:side=>:bottom},
                             'Scrollbar.thumb',  {:side=>:top, :expand=>true}
                           ]}
                         ])

  # Tk::Tile::Style.layout('Horizontal.TScrollbar',
  Tk::Tile::Style.layout(Tk::Tile.style('Horizontal', Tk::Tile::TScrollbar),
                         ['Scrollbar.trough', {:children=>[
                             'Scrollbar.leftarrow',   {:side=>:left},
                             'Scrollbar.rightarrow', {:side=>:right},
                             'Scrollbar.leftarrow',   {:side=>:right},
                             'Scrollbar.thumb',  {:side=>:left, :expand=>true}
                           ]}
                         ])

  #
  # Elements:
  #
  if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
    Tk::Tile::Style.element_create('Button.button',
                                   :image,
                                   [ $images['button-n'],
                                     :pressed, $images['button-p'],
                                     :active,  $images['button-h'],
                                   ], :border=>3, :sticky=>:ew)

    Tk::Tile::Style.element_create('Checkbutton.indicator',
                                   :image,
                                   [ $images['check-nu'],
                                     [:pressed, :selected],$images['check-nc'],
                                     :pressed,             $images['check-nu'],
                                     [:active, :selected], $images['check-hc'],
                                     :active,              $images['check-hu'],
                                     :selected,            $images['check-nc'],
                                   ], :sticky=>:w)

    Tk::Tile::Style.element_create('Radiobutton.indicator',
                                   :image,
                                   [ $images['radio-nu'],
                                     [:pressed,:selected],$images['radio-nc'],
                                     :pressed,            $images['radio-nu'],
                                     [:active,:selected], $images['radio-hc'],
                                     :active,             $images['radio-hu'],
                                     :selected,           $images['radio-nc'],
                                   ], :sticky=>:w)

  elsif TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0
    Tk::Tile::Style.element_create('Button.button',
                                   :image, $images['button-n'],
                                   :map=>[
                                     :pressed, $images['button-p'],
                                     :active,  $images['button-h'],
                                   ], :border=>3, :sticky=>:ew)

    Tk::Tile::Style.element_create('Checkbutton.indicator',
                                   :image, $images['check-nu'],
                                   :map=>[
                                     [:pressed, :selected],$images['check-nc'],
                                     :pressed,             $images['check-nu'],
                                     [:active, :selected], $images['check-hc'],
                                     :active,              $images['check-hu'],
                                     :selected,            $images['check-nc'],
                                   ], :sticky=>:w)

    Tk::Tile::Style.element_create('Radiobutton.indicator',
                                   :image, $images['radio-nu'],
                                   :map=>[
                                     [:pressed, :selected],$images['radio-nc'],
                                     :pressed,             $images['radio-nu'],
                                     [:active, :selected], $images['radio-hc'],
                                     :active,              $images['radio-hu'],
                                     :selected,            $images['radio-nc'],
                                   ], :sticky=>:w)

  else # tile 0.4 or earlier
    Tk::Tile::Style.element_create('Button.button', :pixmap,
                                   :images=>[
                                     :pressed, $images['button-p'],
                                     :active,  $images['button-h'],
                                     '',       $images['button-n']
                                   ], :border=>3, :tiling=>:tile)

    Tk::Tile::Style.element_create('Checkbutton.indicator', :pixmap,
                                   :images=>[
                                     [:pressed, :selected],$images['check-nc'],
                                     :pressed,             $images['check-nu'],
                                     [:active, :selected], $images['check-hc'],
                                     :active,              $images['check-hu'],
                                     :selected,            $images['check-nc'],
                                     '',                   $images['check-nu'],
                                   ], :tiling=>:fixed)

    Tk::Tile::Style.element_create('Radiobutton.indicator', :pixmap,
                                   :images=>[
                                     [:pressed, :selected],$images['radio-nc'],
                                     :pressed,             $images['radio-nu'],
                                     [:active, :selected], $images['radio-hc'],
                                     :active,              $images['radio-hu'],
                                     :selected,            $images['radio-nc'],
                                     '',                   $images['radio-nu'],
                                   ], :tiling=>:fixed)

  end

  #
  # Settings:
  #
  # Tk::Tile::Style.layout(Tk::Tile::TButton,
  Tk::Tile::Style.layout('TButton', [
      'Button.button', {:children=>[
           'Button.focus', {:children=>[
                'Button.padding', {:children=>[
                    'Button.label', {:expand=>true, :sticky=>''}
                ]}
           ]}
      ]}
  ])

  # Tk::Tile::Style.layout(Tk::Tile::TCheckbutton,
  Tk::Tile::Style.layout('TCheckbutton', [
      'Checkbutton.background', # this is not needed in tile 0.5 or later
      'Checkbutton.border', {:children=>[
           'Checkbutton.padding', {:children=>[
                'Checkbutton.indicator', {:side=>:left},
                'Checkbutton.focus', {:side=>:left, :children=>[
                    'Checkbutton.label'
                ]}
           ]}
      ]}
  ])

  # Tk::Tile::Style.layout(Tk::Tile::TRadiobutton,
  Tk::Tile::Style.layout('TRadiobutton', [
      'Radiobutton.background', # this is not needed in tile 0.5 or later
      'Radiobutton.border', {:children=>[
           'Radiobutton.padding', {:children=>[
                'Radiobutton.indicator', {:side=>:left},
                'Radiobutton.focus', {:expand=>true, :sticky=>:w, :children=>[
                    'Radiobutton.label', {:side=>:right, :expand=>true}
                ]}
           ]}
      ]}
  ])
end

Tk::Tile::Style.theme_create('kroc-rb', :parent=>'alt',
                             :settings=>proc{ kroc_rb_settings() })