summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tkextlib/tile/style.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib/tkextlib/tile/style.rb')
-rw-r--r--ext/tk/lib/tkextlib/tile/style.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb
index 098f4e4f72..ca7ee99c32 100644
--- a/ext/tk/lib/tkextlib/tile/style.rb
+++ b/ext/tk/lib/tkextlib/tile/style.rb
@@ -33,6 +33,8 @@ class << Tk::Tile::Style
# conflict with some definitions on Tcl/Tk scripts.
if Tk::Tile::TILE_SPEC_VERSION_ID < 7
def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
unless Tk.info(:commands, '::ttk::style').empty?
# fail RuntimeError,
# "can't define '::ttk::style' command (already exist)"
@@ -59,6 +61,8 @@ class << Tk::Tile::Style
end
else ### TILE_SPEC_VERSION_ID == 7
def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
unless Tk.info(:commands, '::ttk::style').empty?
# fail RuntimeError,
# "can't define '::ttk::style' command (already exist)"
@@ -91,6 +95,8 @@ class << Tk::Tile::Style
TkCommandNames = ['::ttk::style'.freeze].freeze
def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
unless Tk.info(:commands, '::style').empty?
# fail RuntimeError, "can't define '::style' command (already exist)"
@@ -120,6 +126,36 @@ class << Tk::Tile::Style
end
end
+ 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
+ private :__define_themes_and_setTheme_proc__!
+
def configure(style=nil, keys=nil)
if style.kind_of?(Hash)
keys = style