1 # vim: foldmarker=<<<,>>> ft=tcl foldmethod=marker shiftwidth=4 ts=4
3 # Based on the itk::Toplevel class, with the addition of the -menu
4 # link to allow configuring the toplevel's menu
6 class tlc::Mytoplevel {
12 itk_option define -title title Title ""
17 method checkbackground {}
22 configbody tlc::Mytoplevel::title { #<<<
23 wm title $topw $itk_option(-title)
27 body tlc::Mytoplevel::constructor {args} { #<<<
28 set itk_interior [namespace tail $this]
29 set topw $itk_interior
31 itk_component add hull {
32 toplevel $topw -class [namespace tail [info class]]
34 keep -cursor -takefocus -menu -background
36 $topw configure -background \
37 [ttk::style lookup $ttk::currentTheme -background]
38 bind tlc-delete-$topw <Destroy> [code itcl::delete object $this]
39 bindtags $topw [concat [list tlc-delete-$topw] [bindtags $topw]]
40 bind $topw <<ThemeChanged>> [code $this checkbackground]
42 itk_initialize {*}$args
46 body tlc::Mytoplevel::destructor {} { #<<<
47 if {[winfo exists $topw]} {
48 set bindtags [bindtags $topw]
49 set idx [lsearch $bindtags tlc-delete-$topw]
51 bindtags $topw [lreplace $bindtags $idx $idx]
58 body tlc::Mytoplevel::checkbackground {} { #<<<
59 if {[winfo exists $topw]} {
60 set new [ttk::style lookup $ttk::currentTheme -background]
61 $topw configure -background $new