From 15dfe8eee69ce3bc065be8f0cc69963c1404202d Mon Sep 17 00:00:00 2001 From: ocean Date: Tue, 7 Jun 2005 09:04:18 +0000 Subject: [PATCH] * ext/tk/sample/tkextlib/tile/themes/kroc.{rb,tcl}: also support tile 0.4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/ChangeLog.tkextlib | 4 ++++ ext/tk/sample/tkextlib/tile/themes/kroc.rb | 12 +++++++++-- ext/tk/sample/tkextlib/tile/themes/kroc.tcl | 22 ++++++++++++++------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib index 279dcc79be..dc04585985 100644 --- a/ext/tk/ChangeLog.tkextlib +++ b/ext/tk/ChangeLog.tkextlib @@ -1,3 +1,7 @@ +2005-06-07 ocean + + * sample/tkextlib/tile/themes/kroc.{rb,tcl}: also support tile 0.4. + 2005-06-07 ocean * sample/tkextlib/tile/themes/kroc.{rb,tcl}: support tile 0.5 or later. diff --git a/ext/tk/sample/tkextlib/tile/themes/kroc.rb b/ext/tk/sample/tkextlib/tile/themes/kroc.rb index 7886848e40..ab782b8c36 100644 --- a/ext/tk/sample/tkextlib/tile/themes/kroc.rb +++ b/ext/tk/sample/tkextlib/tile/themes/kroc.rb @@ -8,6 +8,12 @@ imgdir = File.join(File.dirname(__FILE__), '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) @@ -52,10 +58,10 @@ def kroc_rb_settings Tk::Tile::Style.default(Tk::Tile::TButton, :padding=>[10,4]) # Tk::Tile::Style.default('TNotebook.Tab', - Tk::Tile::Style.default(Tk::Tile::TNotebook.style('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(Tk::Tile::TNotebook.style('Tab'), + Tk::Tile::Style.map($TNotebook_Tab, :background=>[:selected, '#FCB64F', '', '#FFE6BA'], :foreground=>['', 'black'], :padding=>[:selected, [10, 6, 10, 3]]) @@ -162,6 +168,7 @@ def kroc_rb_settings # 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}, @@ -174,6 +181,7 @@ def kroc_rb_settings # 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}, diff --git a/ext/tk/sample/tkextlib/tile/themes/kroc.tcl b/ext/tk/sample/tkextlib/tile/themes/kroc.tcl index 29ff58d8ea..73548acef2 100644 --- a/ext/tk/sample/tkextlib/tile/themes/kroc.tcl +++ b/ext/tk/sample/tkextlib/tile/themes/kroc.tcl @@ -15,6 +15,12 @@ namespace eval tile::kroc { set imgdir [file join [file dirname [info script]] kroc] array set Images [tile::LoadImages $imgdir *.gif] + if {[package vsatisfies [package provide tile] 0.5]} { + set TNoteBook_Tab TNotebook.Tab + } else { + set TNoteBook_Tab Tab.TNotebook + } + style theme create kroc -parent alt -settings { style default . -background #FCB64F -troughcolor #F8C278 -borderwidth 1 @@ -24,8 +30,8 @@ namespace eval tile::kroc { style default TButton -padding "10 4" - style default TNotebook.Tab -padding {10 3} -font TkDefaultFont - style map TNotebook.Tab \ + style default $TNoteBook_Tab -padding {10 3} -font TkDefaultFont + style map $TNoteBook_Tab \ -background [list selected #FCB64F {} #FFE6BA] \ -foreground [list {} black] \ -padding [list selected {10 6 10 3}] @@ -58,7 +64,7 @@ namespace eval tile::kroc { # Elements: # if {[package vsatisfies [package provide tile] 0.5]} { - + style element create Button.button image $Images(button-n) \ -map [list \ pressed $Images(button-p) \ @@ -82,9 +88,9 @@ namespace eval tile::kroc { active $Images(radio-hu) \ selected $Images(radio-nc) \ ] -sticky w - + } else { - + style element create Button.button pixmap -images [list \ pressed $Images(button-p) \ active $Images(button-h) \ @@ -108,11 +114,11 @@ namespace eval tile::kroc { selected $Images(radio-nc) \ {} $Images(radio-nu) \ ] -tiling fixed - + } # - # Settings: + # Settings: (*button.background is not needed in tile 0.5 or above) # style layout TButton { Button.button -children { @@ -126,6 +132,7 @@ namespace eval tile::kroc { style layout TCheckbutton { Checkbutton.border -children { + Checkbutton.background Checkbutton.padding -children { Checkbutton.indicator -side left Checkbutton.focus -side left -children { @@ -137,6 +144,7 @@ namespace eval tile::kroc { style layout TRadiobutton { Radiobutton.border -children { + Radiobutton.background Radiobutton.padding -children { Radiobutton.indicator -side left Radiobutton.focus -expand true -sticky w -children {