1 |
# /************************************************************\ # |
2 |
# Module: AscConfirm.t |
3 |
# written by Kirk Abbott |
4 |
# Date:$Date: 1997/06/23 18:47:28 $ |
5 |
# Version: $Revision: 1.6 $ |
6 |
# \************************************************************/ # |
7 |
# |
8 |
# Module: AscConfirm.t |
9 |
# Tcl version: 8.0 |
10 |
# Tk version: 8.0 |
11 |
# |
12 |
# AscConfirmid $Id: AscConfirm.t,v 1.6 1997/06/23 18:47:28 ballan Exp $ |
13 |
# |
14 |
# |
15 |
|
16 |
global AscConfirm |
17 |
set AscConfirm(button) 0 |
18 |
|
19 |
# /************************************************************\ # |
20 |
# ascConfirm |
21 |
# Generic confirm/cancel box. Will return the number of the button |
22 |
# pressed. 1 for confirm, 2 for cancel. The box is modal. |
23 |
# Arguments : |
24 |
# AscConfirmGeom -- geometry -- default |
25 |
# AscConfirm(font) -*-* (duh) |
26 |
# \************************************************************/ # |
27 |
|
28 |
set AscConfirm(font) -*-* |
29 |
|
30 |
# |
31 |
# procedures to show window .ascConfirm |
32 |
# |
33 |
proc VShowWindow.ascConfirm {{AscConfirmGeom "190x50"} {yestext "Confirm"} {title "confirmation"}} {# xf ignore me 5 |
34 |
|
35 |
global AscConfirm |
36 |
|
37 |
toplevel .ascConfirm |
38 |
|
39 |
# Window manager configurations |
40 |
global tk_version |
41 |
wm positionfrom .ascConfirm "" |
42 |
wm sizefrom .ascConfirm "" |
43 |
wm minsize .ascConfirm 170 40 |
44 |
wm geometry .ascConfirm $AscConfirmGeom |
45 |
wm title .ascConfirm $title |
46 |
wm protocol .ascConfirm WM_DELETE_WINDOW {bell;bell;bell} |
47 |
|
48 |
|
49 |
# build widget .ascConfirm.main_frm |
50 |
frame .ascConfirm.main_frm |
51 |
|
52 |
# build widget .ascConfirm.main_frm.cancel_btn |
53 |
button .ascConfirm.main_frm.cancel_btn \ |
54 |
-font $AscConfirm(font) \ |
55 |
-text {Cancel} \ |
56 |
-width {7} \ |
57 |
-command " |
58 |
set AscConfirm(button) 2 |
59 |
catch {destroy .ascConfirm}" |
60 |
|
61 |
# build widget .ascConfirm.main_frm.confirm_btn |
62 |
button .ascConfirm.main_frm.confirm_btn \ |
63 |
-font $AscConfirm(font) \ |
64 |
-text "$yestext" \ |
65 |
-width [expr [string length "$yestext"] +1] \ |
66 |
-command " |
67 |
set AscConfirm(button) 1 |
68 |
catch {destroy .ascConfirm}" |
69 |
|
70 |
# pack widget .ascConfirm.main_frm |
71 |
pack append .ascConfirm.main_frm \ |
72 |
.ascConfirm.main_frm.confirm_btn {left frame center expand} \ |
73 |
.ascConfirm.main_frm.cancel_btn {right frame center expand} |
74 |
|
75 |
# pack widget .ascConfirm |
76 |
pack append .ascConfirm \ |
77 |
.ascConfirm.main_frm {top frame center expand fill} |
78 |
|
79 |
# |
80 |
# Get Data and Catch response. |
81 |
# |
82 |
# wait for the box to be destroyed |
83 |
update idletask |
84 |
catch { grab -global .ascConfirm } err |
85 |
tkwait window .ascConfirm |
86 |
return $AscConfirm(button) |
87 |
} |
88 |
|
89 |
proc DestroyWindow.ascConfirm {} {# xf ignore me 5 |
90 |
|
91 |
catch "destroy .ascConfirm" |
92 |
update |
93 |
} |
94 |
# eof |
95 |
# |
96 |
|