Module: Tk::Tile::Style
- Extended by:
- ParseStyleLayout, TkCore
- Defined in:
- ext/lib/tkextlib/tile/style.rb,
ext/lib/tkextlib/tile/style.rb
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_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_str, number, procedure, simplelist, string, #subst, tk_tcl2ruby, uninstall_cmd, #uninstall_cmd, window
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_str, #num_or_str, number, #number, string, #string, uninstall_cmd
Methods included from TkEvent
#install_bind, #install_bind_for_event_class
Class Method Details
.__define_themes_and_setTheme_proc__! ⇒ Object
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
|
# File 'ext/lib/tkextlib/tile/style.rb', line 129
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
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'ext/lib/tkextlib/tile/style.rb', line 159
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
233
234
235
236
237
238
239
|
# File 'ext/lib/tkextlib/tile/style.rb', line 233
def element_create(name, type, *args)
if type == 'image' || type == :image
element_create_image(name, *args)
else
tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
end
end
|
.element_create_image(name, *args) ⇒ Object
241
242
243
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
|
# File 'ext/lib/tkextlib/tile/style.rb', line 241
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_names ⇒ Object
282
283
284
|
# File 'ext/lib/tkextlib/tile/style.rb', line 282
def element_names()
list(tk_call(TkCommandNames[0], 'element', 'names'))
end
|
.element_options(elem) ⇒ Object
286
287
288
|
# File 'ext/lib/tkextlib/tile/style.rb', line 286
def element_options(elem)
simplelist(tk_call(TkCommandNames[0], 'element', 'options', elem))
end
|
.layout(style = nil, spec = nil) ⇒ Object
219
220
221
222
223
224
225
226
227
228
229
230
231
|
# File 'ext/lib/tkextlib/tile/style.rb', line 219
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
212
213
214
215
|
# File 'ext/lib/tkextlib/tile/style.rb', line 212
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
# File 'ext/lib/tkextlib/tile/style.rb', line 180
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
203
204
205
206
|
# File 'ext/lib/tkextlib/tile/style.rb', line 203
def map_configinfo(style=nil, key=None)
style = '.' unless style
map(style, key)
end
|
.map_default_configinfo(key = None) ⇒ Object
208
209
210
|
# File 'ext/lib/tkextlib/tile/style.rb', line 208
def map_default_configinfo(key=None)
map('.', key)
end
|
.theme_create(name, keys = nil) ⇒ Object
290
291
292
293
294
295
296
297
298
|
# File 'ext/lib/tkextlib/tile/style.rb', line 290
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
307
308
309
|
# File 'ext/lib/tkextlib/tile/style.rb', line 307
def theme_names()
list(tk_call(TkCommandNames[0], 'theme', 'names'))
end
|
.theme_settings(name, cmd = nil, &b) ⇒ Object
300
301
302
303
304
305
|
# File 'ext/lib/tkextlib/tile/style.rb', line 300
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
311
312
313
314
315
|
# File 'ext/lib/tkextlib/tile/style.rb', line 311
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
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
|
# File 'ext/lib/tkextlib/tile/style.rb', line 63
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
|