Module: Tk::Tile::Style
Constant Summary
collapse
- TkCommandNames =
TILE_SPEC_VERSION_ID >= 8
['::ttk::style'.freeze].freeze
Constants included
from TkCore
TkCore::EventFlag, TkCore::INTERP, TkCore::INTERP_MUTEX, TkCore::INTERP_ROOT_CHECK, TkCore::INTERP_THREAD, TkCore::INTERP_THREAD_STATUS, TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD, TkCore::WIDGET_DESTROY_HOOK, TkCore::WITH_ENCODING, TkCore::WITH_RUBY_VM
Constants included
from TkComm
TkComm::GET_CONFIGINFO_AS_ARRAY, TkComm::GET_CONFIGINFOwoRES_AS_ARRAY, TkComm::TkExtlibAutoloadModule, TkComm::Tk_CMDTBL, TkComm::Tk_IDs, TkComm::Tk_WINDOWS, TkComm::USE_TCLs_LIST_FUNCTIONS, TkComm::WidgetClassNames
Constants included
from TkUtil
TkUtil::None, TkUtil::RELEASE_DATE
Class Method Summary
collapse
-
.__define_themes_and_setTheme_proc__! ⇒ Object
-
.configure(style = nil, keys = nil) ⇒ Object
(also: default)
-
.element_create(name, type, *args) ⇒ Object
-
.element_create_image(name, *args) ⇒ Object
-
.element_create_vsapi(name, class_name, part_id, *args) ⇒ Object
-
.element_names ⇒ Object
-
.element_options(elem) ⇒ Object
-
.layout(style = nil, spec = nil) ⇒ Object
-
.lookup(style, opt, state = None, fallback_value = None) ⇒ Object
-
.map(style = nil, keys = nil) ⇒ Object
(also: map_configure)
-
.map_configinfo(style = nil, key = None) ⇒ Object
-
.map_default_configinfo(key = None) ⇒ Object
-
.theme_create(name, keys = nil) ⇒ Object
-
.theme_names ⇒ Object
-
.theme_settings(name, cmd = nil, &b) ⇒ Object
-
.theme_use(name) ⇒ Object
Instance Method Summary
collapse
Methods included from TkCore
_tk_call_to_list_core, after, after_cancel, after_idle, appname, appsend, appsend_deny, appsend_displayof, callback, callback_break, callback_continue, callback_return, chooseColor, chooseDirectory, do_one_event, event_generate, getMultipleOpenFile, getMultipleSaveFile, getOpenFile, getSaveFile, get_eventloop_tick, get_eventloop_weight, get_no_event_wait, inactive, inactive_displayof, info, ip_eval, ip_eval_with_enc, ip_eval_without_enc, ip_invoke, ip_invoke_with_enc, ip_invoke_without_enc, is_mainloop?, load_cmd_on_ip, mainloop, mainloop_exist?, mainloop_thread?, mainloop_watchdog, messageBox, rb_appsend, rb_appsend_displayof, reset_inactive, reset_inactive_displayof, restart, scaling, scaling_displayof, set_eventloop_tick, set_eventloop_weight, set_no_event_wait, tk_call, tk_call_to_list, tk_call_to_list_with_enc, tk_call_to_list_without_enc, tk_call_to_simplelist, tk_call_to_simplelist_with_enc, tk_call_to_simplelist_without_enc, tk_call_with_enc, tk_call_without_enc, windowingsystem
Methods included from TkComm
_at, _callback_entry?, _callback_entry_class?, _curr_cmd_id, _fromUTF8, _genobj_for_tkwidget, _next_cmd_id, _toUTF8, array2tk_list, #bind, #bind_all, #bind_append, #bind_append_all, #bind_remove, #bind_remove_all, #bindinfo, #bindinfo_all, bool, image_obj, #install_cmd, install_cmd, list, num_or_nil, num_or_str, number, procedure, simplelist, slice_ary, string, #subst, tk_tcl2ruby, uninstall_cmd, #uninstall_cmd, window
Methods included from TkEvent
#install_bind, #install_bind_for_event_class
Methods included from TkUtil
#_conv_args, _conv_args, #_fromUTF8, #_get_eval_enc_str, _get_eval_enc_str, #_get_eval_string, _get_eval_string, _symbolkey2str, #_symbolkey2str, #_toUTF8, #bool, bool, callback, eval_cmd, #hash_kv, hash_kv, install_cmd, #num_or_nil, num_or_nil, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd, untrust
Class Method Details
.__define_themes_and_setTheme_proc__! ⇒ Object
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
|
# File 'lib/tkextlib/tile/style.rb', line 130
def __define_themes_and_setTheme_proc__!
TkCore::INTERP.add_tk_procs('::ttk::themes', '{ptn *}', <<-'EOS')
#set themes [list]
set themes [::ttk::style theme names]
foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
set theme [namespace tail $pkg]
if {[lsearch -exact $themes $theme] < 0} {
lappend themes $theme
}
}
foreach pkg [lsearch -inline -all -glob [package names] tile::theme::$ptn] {
set theme [namespace tail $pkg]
if {[lsearch -exact $themes $theme] < 0} {
lappend themes $theme
}
}
return $themes
EOS
TkCore::INTERP.add_tk_procs('::ttk::setTheme', 'theme', <<-'EOS')
variable currentTheme
if {[lsearch -exact [::ttk::style theme names] $theme] < 0} {
package require [lsearch -inline -regexp [package names] (ttk|tile)::theme::$theme]
}
::ttk::style theme use $theme
set currentTheme $theme
EOS
end
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/tkextlib/tile/style.rb', line 160
def configure(style=nil, keys=nil)
if style.kind_of?(Hash)
keys = style
style = nil
end
style = '.' unless style
if Tk::Tile::TILE_SPEC_VERSION_ID < 7
sub_cmd = 'default'
else
sub_cmd = 'configure'
end
if keys && keys != None
tk_call(TkCommandNames[0], sub_cmd, style, *hash_kv(keys))
else
tk_call(TkCommandNames[0], sub_cmd, style)
end
end
|
.element_create(name, type, *args) ⇒ Object
234
235
236
237
238
239
240
241
242
|
# File 'lib/tkextlib/tile/style.rb', line 234
def element_create(name, type, *args)
if type == 'image' || type == :image
element_create_image(name, *args)
elsif type == 'vsapi' || type == :vsapi
element_create_vsapi(name, *args)
else
tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
end
end
|
.element_create_image(name, *args) ⇒ Object
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/tkextlib/tile/style.rb', line 244
def element_create_image(name, *args)
fail ArgumentError, 'Must supply a base image' unless (spec = args.shift)
if (opts = args.shift)
if opts.kind_of?(Hash)
opts = _symbolkey2str(opts)
else
fail ArgumentError, 'bad option'
end
end
fail ArgumentError, 'too many arguments' unless args.empty?
if spec.kind_of?(Array)
if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
if opts
tk_call(TkCommandNames[0],
'element', 'create', name, 'image', spec, opts)
else
tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
end
else
fail ArgumentError, 'illegal arguments' if opts.key?('map')
base = spec.shift
opts['map'] = spec
tk_call(TkCommandNames[0],
'element', 'create', name, 'image', base, opts)
end
else
if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
spec = [spec, *(opts.delete('map'))] if opts.key?('map')
end
if opts
tk_call(TkCommandNames[0],
'element', 'create', name, 'image', spec, opts)
else
tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
end
end
end
|
.element_create_vsapi(name, class_name, part_id, *args) ⇒ Object
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
# File 'lib/tkextlib/tile/style.rb', line 285
def element_create_vsapi(name, class_name, part_id, *args)
if (state_map = args.shift || None)
if state_map.kind_of?(Hash)
opts = _symbolkey2str(state_map)
state_map = None
end
end
opts = args.shift || None
fail ArgumentError, "too many arguments" unless args.empty?
tk_call(TkCommandNames[0], 'element', 'create', name, 'vsapi',
class_name, part_id, state_map, opts)
end
|
.element_names ⇒ Object
303
304
305
|
# File 'lib/tkextlib/tile/style.rb', line 303
def element_names()
list(tk_call(TkCommandNames[0], 'element', 'names'))
end
|
.element_options(elem) ⇒ Object
307
308
309
|
# File 'lib/tkextlib/tile/style.rb', line 307
def element_options(elem)
simplelist(tk_call(TkCommandNames[0], 'element', 'options', elem))
end
|
.layout(style = nil, spec = nil) ⇒ Object
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# File 'lib/tkextlib/tile/style.rb', line 220
def layout(style=nil, spec=nil)
if style.kind_of?(Hash)
spec = style
style = nil
end
style = '.' unless style
if spec
tk_call(TkCommandNames[0], 'layout', style, spec)
else
_style_layout(list(tk_call(TkCommandNames[0], 'layout', style)))
end
end
|
.lookup(style, opt, state = None, fallback_value = None) ⇒ Object
213
214
215
216
|
# File 'lib/tkextlib/tile/style.rb', line 213
def lookup(style, opt, state=None, fallback_value=None)
tk_call(TkCommandNames[0], 'lookup', style,
'-' << opt.to_s, state, fallback_value)
end
|
.map(style = nil, keys = nil) ⇒ Object
Also known as:
map_configure
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/tkextlib/tile/style.rb', line 181
def map(style=nil, keys=nil)
if style.kind_of?(Hash)
keys = style
style = nil
end
style = '.' unless style
if keys && keys != None
if keys.kind_of?(Hash)
tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys))
else
simplelist(tk_call(TkCommandNames[0], 'map', style, '-' << keys.to_s))
end
else
ret = {}
Hash[*(simplelist(tk_call(TkCommandNames[0], 'map', style)))].each{|k, v|
ret[k[1..-1]] = list(v)
}
ret
end
end
|
.map_configinfo(style = nil, key = None) ⇒ Object
204
205
206
207
|
# File 'lib/tkextlib/tile/style.rb', line 204
def map_configinfo(style=nil, key=None)
style = '.' unless style
map(style, key)
end
|
.map_default_configinfo(key = None) ⇒ Object
209
210
211
|
# File 'lib/tkextlib/tile/style.rb', line 209
def map_default_configinfo(key=None)
map('.', key)
end
|
.theme_create(name, keys = nil) ⇒ Object
311
312
313
314
315
316
317
318
319
|
# File 'lib/tkextlib/tile/style.rb', line 311
def theme_create(name, keys=nil)
name = name.to_s
if keys && keys != None
tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys))
else
tk_call(TkCommandNames[0], 'theme', 'create', name)
end
name
end
|
.theme_names ⇒ Object
328
329
330
|
# File 'lib/tkextlib/tile/style.rb', line 328
def theme_names()
list(tk_call(TkCommandNames[0], 'theme', 'names'))
end
|
.theme_settings(name, cmd = nil, &b) ⇒ Object
321
322
323
324
325
326
|
# File 'lib/tkextlib/tile/style.rb', line 321
def theme_settings(name, cmd=nil, &b)
name = name.to_s
cmd = Proc.new(&b) if !cmd && b
tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd)
name
end
|
.theme_use(name) ⇒ Object
332
333
334
335
336
|
# File 'lib/tkextlib/tile/style.rb', line 332
def theme_use(name)
name = name.to_s
tk_call(TkCommandNames[0], 'theme', 'use', name)
name
end
|
Instance Method Details
#__define_wrapper_proc_for_compatibility__! ⇒ Object
TILE_SPEC_VERSION_ID == 7
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
|
# File 'lib/tkextlib/tile/style.rb', line 64
def __define_wrapper_proc_for_compatibility__!
__define_themes_and_setTheme_proc__!
unless Tk.info(:commands, '::ttk::style').empty?
warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
return
end
TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
if [string equal [lrange $args 0 1] {element create}] {
if [string equal [lindex $args 3] image] {
set spec [lindex $args 4]
set map [lrange $spec 1 end]
if [llength $map] {
# return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]
}
}
}
# return [eval "::style $args"]
return [uplevel 1 ::style $args]
EOS
end
|