Added custom field type support to Form
[tcl-tlc.git] / scripts / application.itk
blobcf04257ef1d260ed4b8374fcb0acd747f23a8c94
1 # vim: ft=tcl ts=4 shiftwidth=4 foldmethod=marker foldmarker=<<<,>>>
3 proc tlc::application {pathName args} {
4         uplevel tlc::Application $pathName $args
8 class tlc::Application {
9         inherit tlc::Module tlc::Baselog
11         constructor {args} {}
12         destructor {
13                 if {$armed && $::errorInfo != ""} {
14                         log error "\nerror constructing Application: $errmsg\n$::errorInfo"
15                 }
16                 exit 0
17         }
19         public {
20                 variable debug                  0
21                 variable confirm_close  unsaved
22         }
24         protected {
25                 variable armed                  1
26                 variable unsaved_info   ""
28                 method confirm_close    {}
29         }
33 body tlc::Application::constructor {args} { #<<<1
34         eval itk_initialize $args
36         namespace eval $this {}
38         tlc::Gate ${this}::unsaved_info unsaved_info -mode "or"
40         configure -onclose [code $this confirm_close]
42         package require BLT
43         namespace import ::blt::*
45         wm withdraw .
47         tlc::Confirm .confirm -title "Confirm Action"
48         tlc::Deny .deny -title "Permission Denied"
49         tlc::Getinf .getinf -title "Question"
50         tlc::Infowin    .nfo    -title "Information"
52         set armed       0
56 body tlc::Application::confirm_close {} { #<<<1
57         if {$confirm_close == "unsaved"} {
58                 if {
59                         ![${this}::unsaved_info state] 
60                         || [.confirm ask "You have unsaved information!\nAre you sure you want to exit?" Yes No] == "Yes"
61                 } {
62                         delete object $this
63                 }
64         } elseif {$confirm_close} {
65                 if {[.confirm ask "Are you sure you want to exit?" Yes No] == "Yes"} {
66                         delete object $this
67                 }
68         } else {
69                 delete object $this
70         }