source: tol/tolbase/lib/toltk/newButtonDiag2.tcl @ 612d116

1941-docker-image-to-testdevel
Last change on this file since 612d116 was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 8.6 KB
Line 
1# FILE    : newButtonDiag2.tcl
2# PURPOSE : Formulario destinado a los parámetros necesarios para visualizar
3#           Anómalos en el proyecto ForNews.
4#
5# Data Variables para controles:
6#
7#/////////////////////////////////////////////////////////////////////////////
8
9#/////////////////////////////////////////////////////////////////////////////
10namespace eval ::newButtonDiag2 {
11#
12# PURPOSE: Namespace principal del visualizador
13#
14#/////////////////////////////////////////////////////////////////////////////
15  variable widget
16  variable data
17 
18}
19
20#/////////////////////////////////////////////////////////////////////////////
21proc ::newButtonDiag2::Show { args } {
22#
23# PURPOSE: Muestra el formulario, de no existir lo crea
24#
25#/////////////////////////////////////////////////////////////////////////////
26  variable widget
27  variable data
28
29  if { [info exist widget(document)] && [winfo exists $widget(document)] } {
30    if { [$widget(document) cget -state] eq "minimized" } {
31      $widget(document) restore
32    }
33    $widget(document) raise
34  } else {
35    if [llength $args] {
36      eval Create $args
37    } else {
38      Create
39    }
40  }
41 
42}
43
44#/////////////////////////////////////////////////////////////////////////////
45proc ::newButtonDiag2::Create { args } {
46#
47# PURPOSE: Crea un formulario destinado a la Tirada de ForNews
48#
49#/////////////////////////////////////////////////////////////////////////////
50  variable widget
51  variable data
52 
53  array set options {
54    -toolbar ""
55    -cmdlst {}
56  }
57 
58  array set options  $args
59
60  if {[llength $args]} {
61    puts "TIENE ARGS"
62    #read ini
63    ::newButtonDiag2::ReadIni
64   
65    set data(butdig,toolbarfather) $options(-toolbar)
66    set data(butdig,cmdlst)        $options(-cmdlst)
67    puts "data(butdig,cmdlst) -> $data(butdig,cmdlst)"
68  } else {
69    puts "no tiene parametros"
70  }
71
72  set widget(document) [::project::CreateForm \
73    -type [mc {For News}] -iniconfig FORNEWSnewButtonDiag2 \
74    -modal 1 \
75    -height 385 \
76    -width 310 \
77    -resizable 1 \
78    -title [mc {New Button Wizard}] \
79    -closecmd [list ::newButtonDiag2::Destroy]]
80 
81  set tl $widget(document).work
82 
83  set widget(tfwizard)  [CreateTFWizard   $tl]
84  set widget(bbox)      [CreateBBox       $tl]
85
86  grid $widget(tfwizard) -sticky news
87  grid $widget(bbox)     -sticky nes
88 
89  grid rowconfigure    $tl 0  -weight 1
90  grid rowconfigure    $tl 1  -weight 0
91
92  grid columnconfigure $tl 0 -weight 1
93
94}
95
96#/////////////////////////////////////////////////////////////////////////////
97proc ::newButtonDiag2::CreateTFWizard {tl} {
98#
99# PURPOSE: Creamos el frame con las opciones comunes de la ventana
100# PARAMETERS: tl -> path donde creamos el componente
101# RETURN: devolvemos el path del objeto creado
102#
103#/////////////////////////////////////////////////////////////////////////////
104  variable widget
105  variable data
106
107  # titulo
108  set tf [TitleFrame $tl.params \
109    -text [mc {Options}] -bd 1 -side left]
110  set f [$tf getframe]
111 
112  set f1 [frame $f.f1 -bd 0]
113 
114  Label $f1.lePathGCF  -text [mc {Image Selection}]  \
115    -justify left -anchor w
116 
117  set widget(butdig,pathgcf) \
118    [Entry $f1.epathgcf -state normal -width 20 \
119      -textvariable ::newButtonDiag2::data(butdig,imagepath)]
120
121  Button $f1.bPathGCF -compound left -padx 10 \
122    -height 16 -relief link \
123    -helptext [mc {Search image button file}] \
124    -image [Bitmap::get bopen] \
125    -command [list ::newButtonDiag2::GetImagePath]
126 
127  grid $f1.lePathGCF                        -sticky nw
128  grid $widget(butdig,pathgcf) $f1.bPathGCF -sticky news
129 
130  grid columnconfigure $f1 0 -weight 1
131  grid columnconfigure $f1 1 -weight 0
132  grid rowconfigure    $f1 0 -weight 0
133  grid rowconfigure    $f1 1 -weight 0
134 
135  set lstRes {} 
136  set widget(butdig,command) \
137    [beditselector $f.bescommand -label [mc {Form}] \
138      -cols "[mc Form] [mc Commands]" \
139      -selcols "[mc Form]" \
140      -entcols [mc Form] -hlpcols "[mc Form]" \
141      -list $data(butdig,cmdlst) \
142      -readonly false -width 100 \
143      -unique 1]
144 
145  set f2 [frame $f.f2 -bd 0]
146 
147  Label $f2.leTooltip  -text [mc {Tooltip}]  \
148    -justify left -anchor w
149 
150  set widget(butdig,tooltip) \
151    [Entry $f2.etooltip -state normal -width 20 \
152      -textvariable ::newButtonDiag2::data(butdig,tooltip)]
153   
154  grid $f2.leTooltip $widget(butdig,tooltip)  -sticky news
155 
156  grid columnconfigure $f2 0 -weight 0
157  grid columnconfigure $f2 1 -weight 1
158  grid rowconfigure    $f2 0 -weight 0
159
160  grid $f1                     -sticky news
161  grid $widget(butdig,command) -sticky news
162  grid $f2                     -sticky news
163 
164  grid rowconfigure $f 0  -weight 0
165  grid rowconfigure $f 1  -weight 0
166  grid rowconfigure $f 2  -weight 0
167  grid rowconfigure $f 10 -weight 1
168  grid columnconfigure $f 0  -weight 1
169  #grid columnconfigure $f 10 -weight 1
170 
171  return $tf
172}
173
174
175#/////////////////////////////////////////////////////////////////////////////
176proc ::newButtonDiag2::CreateBBox {tl} {
177#
178# PURPOSE: Creamos el frame con las opciones comunes de la ventana
179# PARAMETERS: tl -> path donde creamos el componente
180# RETURN: devolvemos el path del objeto creado
181#
182#/////////////////////////////////////////////////////////////////////////////
183  set bbox \
184    [ButtonBox $tl.bb -orient horizontal -spacing 10 -padx 0 -pady 0 \
185      -homogeneous false]
186 
187  $bbox add -text [mc "Create"] -relief link \
188    -command [list ::newButtonDiag2::Create_command] \
189    -helptext [mc "Create button"] -disabledforeground ""\
190    -image [Bitmap::get ok_txt] -compound left -padx 3 -pady 1
191  $bbox add -text [mc "Exit"] -relief link \
192    -command [list ::newButtonDiag2::Destroy] \
193    -helptext [mc "Close window"] -disabledforeground ""\
194    -image [Bitmap::get exit] -compound left -padx 3 -pady 1
195     
196  return $bbox 
197}
198
199
200#/////////////////////////////////////////////////////////////////////////////
201proc ::newButtonDiag2::ReadIni { } {
202#
203# PURPOSE: Lee del ini
204#
205#/////////////////////////////////////////////////////////////////////////////
206  variable data
207  variable widget
208
209  Tolcon_Trace "Leyendo ini"
210  set rini ::iniFile::Read
211  set key FORNEWSnewButtonDiag2
212 
213}
214
215#/////////////////////////////////////////////////////////////////////////////
216proc ::newButtonDiag2::WriteIni { } {
217#
218# PURPOSE: Escribe en el ini
219#
220#/////////////////////////////////////////////////////////////////////////////
221  variable data
222  variable widget
223   
224  set wini ::iniFile::Write
225  set key FORNEWSnewButtonDiag2
226  Tolcon_Trace "Guardando ini"
227
228  return 1
229}
230
231#/////////////////////////////////////////////////////////////////////////////
232proc ::newButtonDiag2::Destroy { } {
233#
234# PURPOSE: Cerramos la ventana y destruimos toda las variables temporales
235#
236#/////////////////////////////////////////////////////////////////////////////
237  variable data
238  variable widget
239   
240  destroy $widget(document)
241  array unset data
242  array unset widget
243  return 1
244}
245
246#/////////////////////////////////////////////////////////////////////////////
247proc ::newButtonDiag2::Create_command { } {
248#
249# PURPOSE: Creamos el frame con las opciones comunes de la ventana
250# PARAMETERS: tl -> path donde creamos el componente
251# RETURN: devolvemos el path del objeto creado
252#
253#/////////////////////////////////////////////////////////////////////////////
254  variable widget
255  variable data
256 
257  set data(butdig,command) \
258    [$widget(butdig,command) selection get selected [mc Commands]]
259   
260  set ok 0
261 
262  if {[llength $data(butdig,imagepath)]} {
263    set ok 1
264    if {[llength $data(butdig,command)]} {
265      set ok 1
266    } else {
267      set msg [mc {Button command is required}]
268      ShowMessage W $msg $widget(document)
269      set ok 0
270    }
271  } else {
272    set msg [mc {Image button is required}]
273    ShowMessage W $msg $widget(document)
274    set ok 0
275  }
276 
277  if {$ok} {
278    puts "tb  -> $data(butdig,toolbarfather)"
279    puts "pic -> $data(butdig,imagepath)"
280    puts "cmd -> $data(butdig,command)"
281    puts "hlp -> $data(butdig,tooltip)"
282   
283    set Tb  $data(butdig,toolbarfather)
284    set pic $data(butdig,imagepath)
285    eval eval set cmd $data(butdig,command)
286    set hlp $data(butdig,tooltip)
287    set parent [winfo parent $Tb]
288    ::TolConsole::NewButtonB $Tb $pic $hlp $cmd $parent
289    ::newButtonDiag2::Destroy
290  }
291 
292}
293
294#/////////////////////////////////////////////////////////////////////////////
295proc ::newButtonDiag2::GetImagePath {} {
296#
297# PURPOSE: Llama a tk_getOpenFile para guardar el path en la variable data
298#          correspondiente
299#/////////////////////////////////////////////////////////////////////////////
300  variable widget
301  variable data
302 
303  set typelist {{"Gif Files" {".gif"}}}
304  set defExt   .gif
305  set ::newButtonDiag2::data(butdig,imagepath) \
306    [tk_getOpenFile \
307      -defaultextension $defExt \
308      -filetypes $typelist]
309}
310
Note: See TracBrowser for help on using the repository browser.