3
# This file is part of sciGUI toolbox
4
# Copyright (C) 2004 Jaime Urzua Grez
5
# mailto:jaime_urzua@yahoo.com
6
# rev. 0.1 - 2004/06/13
8
# ----------------------------------------------------------------------------
9
# Initial declarations and global variables
10
# ----------------------------------------------------------------------------
15
# ----------------------------------------------------------------------------
16
# Function : sciGUIGenFileName
18
# Description : Return an incremental filename
19
# ----------------------------------------------------------------------------
20
proc sciGUIGenFileName { } {
22
incr sciGUITable(internal,gname)
23
return "sciGUI_$sciGUITable(internal,gname).txt"
27
# ----------------------------------------------------------------------------
28
# Function : sciGUILoadExtra
30
# Description : Load external libs
31
# ----------------------------------------------------------------------------
32
proc sciGUILoadExtra { } {
36
set ff [file join $sciGUITable(internal,path) "tcl" "sciGUI" "local_extra"]
38
source [file join $ff "HelpSystem-1.5" "help.tcl"]
40
source [file join $ff "balloonhelp.tcl"]
42
source [file join $ff "rnotebook.tcl"]
44
source [file join $ff "spinbutton.tcl"]
46
source [file join $ff "combobox-2.3" "combobox.tcl"]
50
# ----------------------------------------------------------------------------
51
# Function : sciGUIDOInit
53
# Description : Initialice Tk/Tcl sciGUI core
54
# ----------------------------------------------------------------------------
55
proc sciGUIDoInit { {path ""} } {
58
set sciGUITable(internal,gname) 0
59
set sciGUITable(internal,path) $path
60
set sciGUITable(win,id) 0
61
set sciGUITable(win,0,type) "null"
62
set sciGUITable(icon,name) ""
63
set sciGUITable(font,1) {-*-helvetica-bold-r-*-*-24}
64
set sciGUITable(font,2) {-*-helvetica-normal-r-*-*-10}
71
# ----------------------------------------------------------------------------
72
# Function : sciGUIGetType
74
# Description : Return type of window
75
# ----------------------------------------------------------------------------
76
proc sciGUIGetType { winId } {
78
set pos [lsearch $sciGUITable(win,id) $winId]
81
set rt "$sciGUITable(win,$winId,type)"
87
# ----------------------------------------------------------------------------
88
# Function : sciGUIName
90
# Description : Return window name
91
# ----------------------------------------------------------------------------
92
proc sciGUIName { winId } {
93
return ".sciGUIwin$winId"
97
# ----------------------------------------------------------------------------
98
# Function : sciGUIDestroy
100
# Description : Destroy window and basic information asociated
101
# ----------------------------------------------------------------------------
102
proc sciGUIDestroy { winId } {
104
if { [sciGUIExist $winId]==1 } {
105
destroy [sciGUIName $winId]
106
set ind [lsearch $sciGUITable(win,id) $winId]
107
set sciGUITable(win,id) [lreplace $sciGUITable(win,id) $ind $ind]
108
unset sciGUITable(win,$winId,type)
109
unset sciGUITable(win,$winId,data)
115
# ----------------------------------------------------------------------------
116
# Function : sciGUICreate
117
# Parameters : winId type wdestroy
118
# Description : Create windows
119
# ----------------------------------------------------------------------------
120
proc sciGUICreate { {winId -1} {type "none"} } {
123
if { $winId == -1 } {
124
set winId2 [lindex $sciGUITable(win,id) end]
127
set pass [sciGUIExist $winId2]
128
if { $pass==1 } { incr winId2 }
131
set wname [sciGUIName $winId2]
132
catch { destroy $wname }
135
lappend sciGUITable(win,id) $winId2
136
set sciGUITable(win,$winId2,type) $type
137
set sciGUITable(win,$winId2,data) ""
142
# ----------------------------------------------------------------------------
143
# Function : sciGUIExist
145
# Description : Retur 1 if window exist, else 0
146
# ----------------------------------------------------------------------------
147
proc sciGUIExist { winId } {
149
set exist [lsearch $sciGUITable(win,id) $winId]
151
if { $exist > -1 } { set output 1 }
156
# ----------------------------------------------------------------------------
157
# Function : sciGUIGifLoad
159
# Description : Load initial gif files
160
# ----------------------------------------------------------------------------
161
proc sciGUIGifLoad { } {
163
set fid [open [file join $sciGUITable(internal,path) "tcl" "sciGUI" "data" "giftable.txt"] r]
164
while { [eof $fid]==0 } {
166
set lineRead [string trimleft $lineRead]
167
set li [string first ":" "$lineRead"]
169
#set pos [llength $sciGUITable(icon,name)]
170
set nam [string range "$lineRead" 0 [expr $li-1]]
171
set lfile [string range "$lineRead" [expr $li+1] end]
172
if { [string first "#" "$nam"] < 0 } {
173
set filename [file join $sciGUITable(internal,path) "tcl" "sciGUI" "data" $lfile]
174
image create photo sciGUITable(gif,$nam) -file $filename
183
# ----------------------------------------------------------------------------
184
# Function : sciGUIIconLoad
186
# Description : Load initial icons
187
# ----------------------------------------------------------------------------
188
proc sciGUIIconLoad { } {
190
set fid [open [file join $sciGUITable(internal,path) "tcl" "sciGUI" "data" "icontable.txt"] r]
191
while { [eof $fid]==0 } {
193
set lineRead [string trimleft $lineRead]
194
set li [string first ":" "$lineRead"]
196
set pos [llength $sciGUITable(icon,name)]
197
set nam [string range "$lineRead" 0 [expr $li-1]]
198
lappend sciGUITable(icon,name) $nam
199
set sciGUITable(icon,$pos) [string range "$lineRead" [expr $li+1] end]
200
image create photo sciGUITable(icon,$nam) -data $sciGUITable(icon,$pos)