Fixes
[tcl-tlc.git] / init.tcl
blobdc060e7e7712be970c698cb8508904858d008c70
1 # vim: foldmarker=<<<,>>>
3 package require TLC-base
5 namespace eval :: {
6 package require Itk 3.1
8 namespace import -force ::itcl::*
9 namespace import -force ::itk::*
11 package require blttable
12 namespace eval ::blt {
13 proc table {args} {
14 return [uplevel [list ::blttable::table] $args]
19 namespace eval ::tlc {
20 namespace eval ::blt {}
21 namespace eval ::blttable {namespace export *}
23 variable version 0.99.0
25 variable guilibrary \
26 [file normalize [file join [pwd] [file dirname [info script]]]]
28 namespace import ::blt::*
29 if {[info commands ::blttable::table] != ""} {
30 catch {namespace import ::blttable::*}
34 lappend auto_path [file join $::tlc::guilibrary scripts]
36 if {[info exists tlc::custom_theme_object]} {
37 set tlc::theme $tlc::custom_theme_object ::#auto]
38 } else {
39 if {[info exists ::tlc_UserThemeOverride]} {
40 set tlc::theme [tlc::Daftheme ::#auto]
41 } else {
42 set tlc::theme [tlc::Theme ::#auto]
46 package provide TLC $::tlc::version
48 # Set saner defaults
50 bind Text <Key-Tab> {tk_focusNext %W}
51 bind Text <Shift-Key-Tab> {tk_focusPrev %W}
53 tlc::Baseconfig tlc::default_config -configfile ""
54 array set tlc::config [tlc::default_config dump_config]
56 # Default options <<<
58 foreach {opt settingkey} {
59 *activeBackground background
60 *highlightBackground highlightbackground
61 *highlightColor highlightcolor
62 *font font
63 *labelFont font
64 *textFont font
65 *selectBorderWidth selectborderwidth
66 *selectBackground selectbackground
67 *selectForeground selectforeground
68 *Tabset*selectBackground background
69 *textBackground textbackground
70 *Listbox.background textbackground
71 *disabledBackground disabledbackground
72 *Entry.disabledForeground disabledforeground
73 *Text.disabledForeground disabledforeground
74 *Text.TextHighlightBackground texthighlightbackground
75 *.hidebg hidebg
76 *enabledBackground textbackground
77 *TreeView.background textbackground
78 *TreeView.borderwidth borderwidth
79 *TreeView.highlightThickness borderwidth
80 *Labelframe.font boldfont
81 *labelFont boldfont
82 *Button.padY button_pady
83 *Form.padding formpadding
84 } {
85 option add $opt [$tlc::theme setting $settingkey] startupFile
88 # Hacks. userdefault priority == 60
89 foreach {opt settingkey} {
90 *Entry.background textbackground
91 *Entry.highlightBackground background
92 *TreeCtrl.background textbackground
93 } {
94 option add $opt [$tlc::theme setting $settingkey] 61
97 switch -exact $tcl_platform(platform) {
98 "unix" {
99 option add *Scrollbar.width 12 startupFile
100 option add *Scrollbar.borderWidth 1 startupFile
101 option add *sbWidth 12 startupFile
102 option add *scrollMargin 0 startupFile
103 option add *elementBorderWidth 1 startupFile
104 option add *textFont [$tlc::theme setting font] startupFile
105 option add *Menu.font [$tlc::theme setting boldfont] startupFile
106 option add *Menu.borderWidth 1 startupFile
108 "windows" {
109 option add *Radiobutton.borderWidth 0 startupFile
110 option add *Checkbutton.borderWidth 0 startupFile
111 option add *Entry.highlightThickness 0 startupFile
114 #>>>
116 namespace eval tlc::Form {
117 variable custom_types
118 set custom_types(sql_lookup) "tlc::form::Datavaultlookup"
120 namespace eval tlc::Pagedform {
121 variable custom_types
122 set custom_types(form) "tlc::Pagedform::Form"
123 set custom_types(html) "tlc::Pagedform::Html"
126 namespace eval tlc {
127 proc set_theme {name} {
128 ttk::setTheme $name
130 ttk::style map TLabel -foreground {invalid red}
133 # Try to choose a reasonable default
134 apply {{} {
135 switch -- [tk windowingsystem] {
136 "win32" {
137 set try [list xpnative winnative clam]
140 "aqua" {
141 set try [list aqua clam]
144 default -
145 "x11" {
146 set try [list clam]
150 foreach theme $try {
151 if {[catch {
152 ::tlc::set_theme $try
153 } errmsg]} {
154 #puts "Could not use theme: ($theme): $errmsg\n$::errorInfo"
155 } else {
156 break