1######################################################################### 2# COPYRIGHT (C) 2003 EDF R&D WWW.CODE-ASTER.ORG # 3# # 4# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR # 5# MODIFY IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS # 6# PUBLISHED BY THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE # 7# LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. # 8# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, # 9# BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF # 10# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU # 11# GENERAL PUBLIC LICENSE FOR MORE DETAILS. # 12# # 13# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE # 14# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO : EDF R&D CODE_ASTER, # 15# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. # 16######################################################################### 17 18# $Id: ihm_main.tcl 2881 2007-03-20 12:30:18Z courtois $ 19 20# construction de la fenetre principale de l'interface 21################################################################# 22proc astk_princ { { REINI "INI" } } { 23# message de mise à jour 24 set client_vers "00.00.00" 25 if { [regexp {([0-9]+)\.([0-9]+)\.([0-9]+)} $astk::astk_version mat1 i1 i2 i3] } { 26 set client_vers [format "%02d.%02d.%02d" $i1 $i2 $i3] 27 } 28 if { $astk::config(-1,flag_maj) != $client_vers } { 29 if { $ashare::origine != "from_salome" } { 30 tk_messageBox -title [ashare::mess ihm 138] -message [ashare::mess ihm 242] -type ok -icon info 31 } 32 set astk::config(-1,flag_maj) $client_vers 33 ashare::save_prefs 34 } 35 36# fenetre principale 37 ashare::pointeur off 38 39 # Titre de la fenetre + menu + creation de la frame complete + icon 40 set_titre 41 set_icon 42 # on fixe la taille de la fenetre 43#if_not_resizable wm resizable . 0 0 44 wm protocol . WM_DELETE_WINDOW { quitter } 45 46 pack [frame $astk::ihm(menu) -relief raised -bd 0 -background $astk::ihm(couleur,menu_background)] -fill x -side top -anchor nw 47 pack [frame .fen -relief raised -bd 0] -fill both -expand 1 -anchor nw 48 grid [frame $astk::ihm(fenetre) -relief raised -bd 1] -row 0 -column 0 -sticky nsew 49 grid [frame $astk::ihm(satellite) -relief raised -bd 1] -row 0 -column 1 -sticky nsw 50 grid [frame $astk::ihm(status) -relief raised -bd 0] -row 1 -columnspan 2 -sticky nsew 51 grid columnconfigure .fen 0 -weight 1 52 grid rowconfigure .fen 0 -weight 1 53 54# pack [frame $astk::ihm(fenetre) -relief raised -bd 1] -side left -fill both -expand 1 -anchor nw 55# pack [frame $astk::ihm(satellite) -relief raised -bd 1] -fill y -expand 1 -anchor nw 56# pack [frame $astk::ihm(status) -relief raised -bd 0] -fill x -anchor s -expand 1 57# pack [panedwindow .fen -orient horizontal] -expand 1 -fill both -anchor nw 58# .fen add [frame $astk::ihm(fenetre) -relief raised -bd 0] 59# .fen add [frame $astk::ihm(satellite) -relief raised -bd 0] 60 61 # barre de menu 62 create_popup $astk::ihm(popup) 63 create_menu $astk::ihm(menu) 64 65 # frame "satellite" 66 affiche_satellite 67 68 # etat, aide... 69 affiche_status 70 71 # il est nécessaire d'afficher l'onglet en dernier car c'est lui qui bride 72 # la taille de la fenetre 73 pack [frame $astk::ihm(fenetre).onglet] -anchor w 74 # creation et initialisation des onglets 75 init_onglet 76 77 # lecture du profil initial ou export 78 if { $astk::ihm(profil_ini) != "" } { 79 ouvrir $astk::ihm(serv_ini) $astk::ihm(profil_ini) 80 set astk::ihm(profil_ini) "" 81 } elseif { $astk::ihm(export_ini) != "" } { 82 import_from "astk_serv" -1 $astk::ihm(export_ini) "non" "oui" 83 set astk::ihm(export_ini) "" 84 } else { 85 # pour le demarrage 86 affiche_onglet $astk::profil(onglet_actif) 87 } 88 89 # cree la liste des noeuds, des versions, choix batch/interactif... 90 maj_sat 91 92 # fenetre init 93 catch {destroy .fen_about} 94 catch {destroy $astk::ihm(asjob)} 95 show_fen $astk::ihm(asjob) 96 97 # affichage 98 ashare::pointeur on 99 update idletasks 100 wm deiconify . 101 ashare::trace_geom astk . 102} 103 104# raffraichir la fenetre principale de l'interface 105################################################################# 106proc raffr_princ { } { 107 global ongsel 108# sous-onglets sélectionnés 109 for {set i 1} {$i <= $astk::ihm(nbongM)} {incr i} { 110 for {set j 1} {$j <= $astk::ihm(nbong,$i)} {incr j} { 111 if { $ongsel($i) == $astk::ihm(tit,$i,$j) } { 112 set ongsel($i) $j 113 } 114 } 115 } 116# réinitialisation du nom des onglets 117 def_onglet 118 for {set i 1} {$i <= $astk::ihm(nbongM)} {incr i} { 119 set ongsel($i) $astk::ihm(tit,$i,$ongsel($i)) 120 } 121# détruit les fenêtres filles et ouvre de nouveau asjob s'il existait 122 set iasj [winfo exists $astk::ihm(asjob)] 123# ne pas détruire les classes BWidgets 124# eval destroy [winfo children .] 125 set lw [winfo children .] 126 for {set i 0} {$i < [llength $lw]} {incr i} { 127 set ww [lindex $lw $i] 128 if { [string match ".#BWidget*" $ww] == 0 } { 129 destroy $ww 130 } 131 } 132# réaffichage 133 astk_princ DETR 134 if { $iasj } { 135 show_fen $astk::ihm(asjob) force 136 } 137 raise . 138} 139 140# change le thème de couleur (voir init_couleur pour les thèmes) 141################################################################# 142proc change_couleur { theme } { 143 set astk::ihm(style,couleur) $theme 144 set astk::config(-1,couleur) $theme 145 set astk::config(-1,theme) $theme 146 ashare::save_prefs 147 init_couleur 148 init_icon $theme 149 raffr_princ 150} 151 152# permet de changer les couleurs à la main 153################################################################# 154proc perso_couleur { } { 155 global tmp_coul 156# récupère les couleurs actuelles 157 set old_coul $astk::ihm(style,couleur) 158 set astk::ihm(style,couleur) perso 159 init_couleur "ras" 160 set lmv [array get astk::ihm] 161 set nbl [expr [llength $lmv] / 2] 162 set lmcle [list] 163 set lcoul [list] 164 set nn 0 165 for {set i 0} {$i < $nbl} {incr i} { 166 set k [expr $i * 2] 167 set k1 [expr $k + 1] 168 if { [regexp {^couleur,(.*)} [lindex $lmv $k] mat1 mcle] } { 169 incr nn 170 lappend lmcle $mcle 171 lappend lcoul [lindex $lmv $k1] 172 } 173 } 174 set lmcle [lsort $lmcle] 175# fenetre 176 set fen .fen_coul 177 catch {destroy $fen} 178 toplevel $fen 179 wm withdraw $fen 180 wm transient $fen . 181 wm title $fen [ashare::mess ihm 328] 182 183 pack [frame $fen.liste -relief solid -bd 1] 184 185# boucle sur les couleurs 186 for {set i 0} {$i < $nn} {incr i} { 187 set mcle [lindex $lmcle $i] 188 set tmp_coul($mcle) $astk::ihm(couleur,$mcle) 189 if { $mcle != "foreground" } { 190 set fgc $astk::ihm(couleur,foreground) 191 } else { 192 set fgc $astk::ihm(couleur,entry_background) 193 } 194 pack [frame $fen.liste.l_$i -relief solid -bd 0] -anchor w 195 label $fen.liste.l_$i.lbl -font $astk::ihm(font,lab) -text $mcle -width 35 -anchor w 196 button $fen.liste.l_$i.butt -width 30 -font $astk::ihm(font,val) -text [ashare::mess ihm 329] \ 197 -fg $fgc \ 198 -bg $astk::ihm(couleur,$mcle) \ 199 -command "choix_couleur $mcle $fen $fen.liste.l_$i.butt" 200 pack $fen.liste.l_$i.lbl $fen.liste.l_$i.butt -pady 3 -side left 201 } 202 203# ok 204 pack [frame $fen.valid -relief solid -bd 0] 205 button $fen.valid.annuler -font $astk::ihm(font,labbout) -text [ashare::mess ihm 85] \ 206 -bg $astk::ihm(couleur,annul) \ 207 -command "set astk::ihm(style,couleur) $old_coul ; init_couleur ras ; destroy $fen" 208 button $fen.valid.ok -font $astk::ihm(font,labbout) -text "Ok" \ 209 -bg $astk::ihm(couleur,valid) \ 210 -command "set astk::ihm(style,couleur) $old_coul ; init_couleur ras ; accept_couleur ; destroy $fen" 211 pack $fen.valid.ok $fen.valid.annuler -side left -padx 10 -pady 5 212 213 wm deiconify $fen 214} 215 216# choisit une couleur 217################################################################# 218proc choix_couleur { mcle fen w } { 219 global tmp_coul 220 set tmp_coul($mcle) [tk_chooseColor -title "Choose a color" -parent $fen \ 221 -initialcolor $astk::ihm(couleur,$mcle)] 222 if { $tmp_coul($mcle) != "" } { 223 $w configure -bg $tmp_coul($mcle) 224 } 225} 226 227# accepte les couleurs 228################################################################# 229proc accept_couleur { } { 230 global tmp_coul 231 set id [open $astk::fic_color w] 232 puts $id "# AUTOMATICALLY GENERATED - DO NOT EDIT !" 233 puts $id "astkrc_version : $ashare::astkrc_version" 234 puts $id "#" 235 set lmv [array get tmp_coul] 236 set nbl [expr [llength $lmv] / 2] 237 for {set i 0} {$i < $nbl} {incr i} { 238 set k [expr $i * 2] 239 set k1 [expr $k + 1] 240 set mcle [lindex $lmv $k] 241 set astk::ihm(couleur,$mcle) $tmp_coul($mcle) 242 puts $id "$mcle : $tmp_coul($mcle)" 243 } 244 close $id 245 if { $astk::ihm(style,couleur) == "perso" } { 246 change_couleur perso 247 } 248} 249 250# choix des polices 251################################################################# 252proc change_font { } { 253# fenetre 254 set fen .fen_font 255 catch {destroy $fen} 256 toplevel $fen 257 wm withdraw $fen 258 wm transient $fen . 259 wm title $fen [ashare::mess ihm 331] 260 261 pack [frame $fen.liste -relief solid -bd 1] -padx 10 -pady 10 262 263 set lf $astk::ihm(style,fontlist) 264 set lm $astk::ihm(style,fontlist_label) 265 for {set i 0} {$i < [llength $lf]} {incr i} { 266 set ff [lindex $lf $i] 267 set msg [ashare::mess ihm [lindex $lm $i]] 268 button $fen.liste.$ff -font $astk::ihm(style,font_$ff) -text $msg \ 269 -command "choix_font $fen $ff" 270 grid $fen.liste.$ff -row $i -column 0 -sticky ew -padx 5 -pady 5 271 } 272 273# ok 274 pack [frame $fen.valid -relief solid -bd 0] 275 button $fen.valid.ok -font $astk::ihm(font,labbout) -text "Ok" \ 276 -bg $astk::ihm(couleur,valid) \ 277 -command "destroy $fen" 278 pack $fen.valid.ok -side left -padx 10 -pady 5 279 280 ashare::centre_fen $fen . 281 wm deiconify $fen 282} 283 284# sélection d'une police 285# groupe = main, fixe 286################################################################# 287proc choix_font { parent groupe } { 288 set newfont [SelectFont .fontdlg -parent $parent -font $astk::ihm(style,font_$groupe)] 289 if { $newfont != "" } { 290 if { $ashare::dbg >= 4 } { 291 ashare::log "<DEBUG> Font : $newfont" 292 } 293 set astk::ihm(style,font_$groupe) $newfont 294 init_font 295 ashare::save_prefs 296 destroy $parent 297 raffr_princ 298 } 299} 300