~ubuntu-branches/ubuntu/maverick/tablelist/maverick

« back to all changes in this revision

Viewing changes to scripts/tablelistWidget.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-05-04 22:00:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090504220015-z56u2jgkkmd0pxh2
Tags: 4.11-0ubuntu1
* New upstream release.
* Install the demo/* files with dh_installexamples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#   - Private procedures implementing the tablelist widget command
9
9
#   - Private callback procedures
10
10
#
11
 
# Copyright (c) 2000-2008  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
 
11
# Copyright (c) 2000-2009  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
12
12
#==============================================================================
13
13
 
14
14
#
90
90
        -borderwidth             {borderWidth             BorderWidth         f}
91
91
        -bd                      -borderwidth
92
92
        -columns                 {columns                 Columns             w}
 
93
        -columntitles            {columnTitles            ColumnTitles        w}
93
94
        -cursor                  {cursor                  Cursor              c}
94
95
        -disabledforeground      {disabledForeground      DisabledForeground  w}
95
96
        -editendcommand          {editEndCommand          EditEndCommand      w}
351
352
    variable activeStyles       [list frame none underline]
352
353
    variable alignments         [list left right center]
353
354
    variable arrowStyles        [list flat7x4 flat7x5 flat7x7 flat8x5 flat9x5 \
354
 
                                      sunken8x7 sunken10x9 sunken12x11]
 
355
                                 sunken8x7 sunken10x9 sunken12x11]
355
356
    variable arrowTypes         [list up down]
356
357
    variable colWidthOpts       [list -requested -stretched -total]
357
358
    variable states             [list disabled normal]
466
467
    #
467
468
    # Define some mouse bindings for the binding tag TablelistLabel
468
469
    #
469
 
    bind TablelistLabel <Enter>         { tablelist::labelEnter    %W %X %Y %x }
470
 
    bind TablelistLabel <Motion>        { tablelist::labelEnter    %W %X %Y %x }
471
 
    bind TablelistLabel <Leave>         { tablelist::labelLeave    %W %X %x %y }
472
 
    bind TablelistLabel <Button-1>      { tablelist::labelB1Down   %W %x 0 }
 
470
    bind TablelistLabel <Enter>           { tablelist::labelEnter  %W %X %Y %x }
 
471
    bind TablelistLabel <Motion>          { tablelist::labelEnter  %W %X %Y %x }
 
472
    bind TablelistLabel <Leave>           { tablelist::labelLeave  %W %X %x %y }
 
473
    bind TablelistLabel <Button-1>        { tablelist::labelB1Down %W %x 0 }
473
474
    bind TablelistLabel <Shift-Button-1>  { tablelist::labelB1Down %W %x 1 }
474
475
    bind TablelistLabel <B1-Motion>     { tablelist::labelB1Motion %W %X %x %y }
475
476
    bind TablelistLabel <B1-Enter>      { tablelist::labelB1Enter  %W }
477
478
    bind TablelistLabel <ButtonRelease-1> { tablelist::labelB1Up   %W %X}
478
479
    bind TablelistLabel <<Button3>>       { tablelist::labelB3Down %W 0 }
479
480
    bind TablelistLabel <<ShiftButton3>>  { tablelist::labelB3Down %W 1 }
 
481
    bind TablelistLabel <Double-Button-1>       { tablelist::labelDblB1 %W %x 0}
 
482
    bind TablelistLabel <Shift-Double-Button-1> { tablelist::labelDblB1 %W %x 1}
480
483
 
481
484
    #
482
485
    # Define the binding tags TablelistSubLabel and TablelistArrow
1034
1037
    #
1035
1038
    variable configSpecs
1036
1039
    set opt [mwutil::fullConfigOpt [lindex $argList 0] configSpecs]
1037
 
    upvar ::tablelist::ns${win}::data data
1038
 
    return $data($opt)
 
1040
    return [doCget $win $opt]
1039
1041
}
1040
1042
 
1041
1043
#------------------------------------------------------------------------------
1047
1049
                              name value ...?"
1048
1050
    }
1049
1051
 
1050
 
    synchronize $win
1051
1052
    set col [colIndex $win [lindex $argList 0] 1]
1052
1053
    return [mwutil::attribSubCmd $win $col [lrange $argList 1 end]]
1053
1054
}
1060
1061
        mwutil::wrongNumArgs "$win columncget columnIndex option"
1061
1062
    }
1062
1063
 
1063
 
    synchronize $win
1064
1064
    set col [colIndex $win [lindex $argList 0] 1]
1065
1065
    variable colConfigSpecs
1066
1066
    set opt [mwutil::fullConfigOpt [lindex $argList 1] colConfigSpecs]
1253
1253
# tablelist::configureSubCmd
1254
1254
#------------------------------------------------------------------------------
1255
1255
proc tablelist::configureSubCmd {win argList} {
1256
 
    synchronize $win
1257
 
    displayItems $win
1258
1256
    variable configSpecs
1259
1257
    return [mwutil::configureSubCmd $win configSpecs tablelist::doConfig \
1260
1258
            tablelist::doCget $argList]
1827
1825
        mwutil::wrongNumArgs "$win hascolumnattrib columnIndex name"
1828
1826
    }
1829
1827
 
1830
 
    synchronize $win
1831
1828
    set col [colIndex $win [lindex $argList 0] 1]
1832
1829
    return [mwutil::hasattribSubCmd $win $col [lindex $argList 1]]
1833
1830
}
2134
2131
    }
2135
2132
 
2136
2133
    set x [format "%d" [lindex $argList 0]]
2137
 
    synchronize $win
2138
 
    displayItems $win
2139
2134
    return [colIndex $win @$x,0 0]
2140
2135
}
2141
2136
 
2630
2625
            rowSelection $win set $row $row
2631
2626
        }
2632
2627
    }
 
2628
 
 
2629
    event generate $win <<TablelistColHiddenStateChanged>>
2633
2630
    return ""
2634
2631
}
2635
2632
 
2651
2648
    # Toggle the value of the -hide option of the specified rows
2652
2649
    #
2653
2650
    upvar ::tablelist::ns${win}::data data
 
2651
    set count 0
2654
2652
    if {$argCount == 1} {
2655
2653
        foreach elem $first {
2656
2654
            set row [rowIndex $win $elem 0]
2659
2657
            }
2660
2658
 
2661
2659
            doRowConfig $row $win -hide [expr {![doRowCget $row $win -hide]}]
 
2660
            incr count
2662
2661
        }
2663
2662
    } else {
2664
2663
        set firstRow [rowIndex $win $first 0]
2673
2672
 
2674
2673
        for {set row $firstRow} {$row <= $lastRow} {incr row} {
2675
2674
            doRowConfig $row $win -hide [expr {![doRowCget $row $win -hide]}]
 
2675
            incr count
2676
2676
        }
2677
2677
    }
 
2678
 
 
2679
    if {$count != 0} {
 
2680
        event generate $win <<TablelistRowHiddenStateChanged>>
 
2681
    }
 
2682
    return ""
2678
2683
}
2679
2684
 
2680
2685
#------------------------------------------------------------------------------
2711
2716
        mwutil::wrongNumArgs "$win unsetcolumnattrib columnIndex name"
2712
2717
    }
2713
2718
 
2714
 
    synchronize $win
2715
2719
    set col [colIndex $win [lindex $argList 0] 1]
2716
2720
    return [mwutil::unsetattribSubCmd $win $col [lindex $argList 1]]
2717
2721
}
2759
2763
# tablelist::xviewSubCmd
2760
2764
#------------------------------------------------------------------------------
2761
2765
proc tablelist::xviewSubCmd {win argList} {
2762
 
    synchronize $win
2763
 
    displayItems $win
 
2766
    set argCount [llength $argList]
 
2767
    if {$argCount != 1 || [lindex $argList 0] != 0} {
 
2768
        synchronize $win
 
2769
        displayItems $win
 
2770
    }
2764
2771
    upvar ::tablelist::ns${win}::data data
2765
2772
 
2766
 
    switch [llength $argList] {
 
2773
    switch $argCount {
2767
2774
        0 {
2768
2775
            #
2769
2776
            # Command: $win xview
2899
2906
# tablelist::yviewSubCmd
2900
2907
#------------------------------------------------------------------------------
2901
2908
proc tablelist::yviewSubCmd {win argList} {
2902
 
    synchronize $win
2903
 
    displayItems $win
 
2909
    set argCount [llength $argList]
 
2910
    if {$argCount != 1 || [lindex $argList 0] != 0} {
 
2911
        synchronize $win
 
2912
        displayItems $win
 
2913
    }
2904
2914
    upvar ::tablelist::ns${win}::data data
2905
2915
    set w $data(body)
2906
2916
 
2907
 
    switch [llength $argList] {
 
2917
    switch $argCount {
2908
2918
        0 {
2909
2919
            #
2910
2920
            # Command: $win yview
2920
2930
            set topRow [expr {int($topTextIdx) - 1}]
2921
2931
            set btmRow [expr {int($btmTextIdx) - 1}]
2922
2932
            foreach {x y width height baselinePos} [$w dlineinfo $topTextIdx] {}
2923
 
            if {$y < 0} {                                ;# top row incomplete
2924
 
                incr topRow
 
2933
            if {$y < 0} {
 
2934
                incr topRow     ;# top row incomplete in vertical direction
2925
2935
            }
2926
2936
            foreach {x y width height baselinePos} [$w dlineinfo $btmTextIdx] {}
2927
2937
            set y2 [expr {$y + $height}]
2928
 
            if {[$w index @0,$y] == [$w index @0,$y2]} { ;# btm row incomplete
2929
 
                incr btmRow -1
 
2938
            if {[string compare [$w index @0,$y] [$w index @0,$y2]] == 0} {
 
2939
                incr btmRow -1  ;# btm row incomplete in vertical direction
2930
2940
            }
2931
2941
            set upperNonHiddenCount \
2932
2942
                [getNonHiddenRowCount $win 0 [expr {$topRow - 1}]]
3598
3608
        adjustRowIndex $win data(anchorRow) 1
3599
3609
    }
3600
3610
    if {$last < $data(activeRow)} {
3601
 
        incr data(activeRow) -$count
3602
 
        adjustRowIndex $win data(activeRow) 1
 
3611
        set activeRow $data(activeRow)
 
3612
        incr activeRow -$count
 
3613
        adjustRowIndex $win activeRow 1
 
3614
        set data(activeRow) $activeRow
3603
3615
    } elseif {$first <= $data(activeRow)} {
3604
 
        set data(activeRow) $first
3605
 
        adjustRowIndex $win data(activeRow) 1
 
3616
        set activeRow $first
 
3617
        adjustRowIndex $win activeRow 1
 
3618
        set data(activeRow) $activeRow
3606
3619
    }
3607
3620
 
3608
3621
    #
3812
3825
        adjustRowIndex $win data(anchorRow) 1
3813
3826
    }
3814
3827
    if {$index <= $data(activeRow)} {
3815
 
        incr data(activeRow) $argCount
3816
 
        adjustRowIndex $win data(activeRow) 1
 
3828
        set activeRow $data(activeRow)
 
3829
        incr activeRow $argCount
 
3830
        adjustRowIndex $win activeRow 1
 
3831
        set data(activeRow) $activeRow
3817
3832
    }
3818
3833
 
3819
3834
    #