Changeset cc64b09 in tol for tolbase/lib/wtree/wtree.tcl


Ignore:
Timestamp:
Nov 24, 2016, 11:58:38 AM (10 years ago)
Author:
Pedro Gea <pgea@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
f738c05
Parents:
6dc91d2
Message:

Refs #1933
Se revisan los binds respecto a wtree y su treectrl.
Se quitan los métodos específicos para la creación de columnas e inserción de nodos que quedaban en tolinspe.
Se añade un update del nodo de paquetes para que se actualice ante un "require".
Se revisan los métodos de botón derecho para que aparezcan sólo sobre los objetos seleccionados.
Se añade un método a wtree para gestionar el color de todas las columnas de un nodo.
Se añaden las columnas al root de wtree.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tolbase/lib/wtree/wtree.tcl

    r6dc91d2 rcc64b09  
    280280    }
    281281  }
     282 
     283  method item-identify {x y} {
     284    $self identify
     285 
     286  }
    282287
    283288  constructor { args } {
    … …  
    347352        [ mymethod EditCallback accept %I %C %E %t ]
    348353
    349     bind $tree <ButtonPress-1> [ mymethod OnButtonPress1 %x %y ]
    350     bind $tree <Control-ButtonPress-1> { }
    351     bind $tree <Shift-ButtonPress-1> { }
     354    #@ El bind se hace con $self para poder ser modificado externamente
     355    #@ Hay mas binds en _configure_bindings
     356    bind $self <ButtonPress-1>         [mymethod OnButtonPress1 %x %y]
     357    bind $self <Control-ButtonPress-1> {}
     358    bind $self <Shift-ButtonPress-1>   {}
    352359
    353360    set height [font metrics [$tree cget -font] -linespace]
    … …  
    393400
    394401    focus $tree
    395 
     402   
     403    #@ Se antepone la configuración de $args para que el nodo root esté o no
     404    #@ y se le pueda aplicar la configuración de columnas
     405    $self configurelist $args
    396406    $self _configure_bindings
    397407    $self _conf-columns -columns $options(-columns)
    398408    $self _conf-contextmenu -contextmenu $options(-contextmenu)
    399     $self configurelist $args
     409
    400410    if { !$options(-filter) } {
    401411      grid remove $win.frameFilter
    … …  
    410420  method CancelEdit { } {
    411421    ::TreeCtrl::EditClose $tree entry 0 0
     422  }
     423 
     424  method item-color { item color } {
     425    set args {}
     426    set first 1
     427    foreach c [ $tree column list ] {
     428      # extraigo el style asociado a la columna
     429      set columnStyle [ $tree column cget $c -itemstyle ]
     430      # extraigo los elementos del style
     431      set styleElements [ $tree style elements $columnStyle ]
     432      # busco si eTXT es uno de esos elementos
     433      if { [ lsearch $styleElements "eTXT" ] != -1 } {
     434        if { $first } {
     435          set first 0
     436        } else {
     437          lappend args {,}
     438        }
     439        lappend args $c eTXT -fill $color
     440      }
     441    }
     442    return [eval $self item element configure $item $args]
    412443  }
    413444
    … …  
    425456      # busco si eTXT es uno de esos elementos
    426457      if { [ lsearch $styleElements "eTXT" ] != -1 } {
    427         # el root no tiene styles
     458        # el root no tiene styles | #@ ya sí
    428459        catch {
    429460          append itemText [ $tree item element cget $item $c eTXT -text ] " "
    … …  
    649680  method _configure_bindings { } {
    650681
    651     bind $tree <Double-ButtonPress-1> "[mymethod DoubleButton1 %W %x %y] ; break"
    652     bind $tree <Return> "[mymethod KeyPressReturn %W] ; break"
    653 
    654     bind $tree <ButtonPress-3> [ mymethod Button3 %W %x %y %X %Y]
    655 
    656     bind $tree <Escape> "[mymethod KeyPressEscape] ; break"
     682    #@ El bind se hace con $self para poder ser modificado externamente
     683    #@ Hay mas binds en el constructor
     684    bind $self <Double-ButtonPress-1> "[mymethod DoubleButton1 %W %x %y] ; break"
     685    bind $self <Return>               "[mymethod KeyPressReturn %W] ; break"
     686    bind $self <ButtonPress-3>         [mymethod Button3 %W %x %y %X %Y]
     687    bind $self <Escape>              "[mymethod KeyPressEscape] ; break"
    657688
    658689    $tree notify bind $tree <Header-invoke> [mymethod SortbyColumn %W %C]
    … …  
    773804                      -image $opts(-image) \
    774805                      -itembackground "\#e0e8f0 {}" \
    775                       -tags $opts(-tags) ]
     806                      -tags $opts(-tags) -expand 1]
    776807      # "
    777808      set column_info($idx,ID) $colID
    … …  
    801832      # asocio el style a la columna
    802833      $tree column configure $colID -itemstyle $s
     834     
     835      #@ Se añaden las columnas al nodo root si está visible
     836      if { [$tree cget -showroot] } {
     837        $tree item style set root $colID $s
     838      }
     839     
    803840      incr idx
    804841    }
Note: See TracChangeset for help on using the changeset viewer.