OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [libgui/] [src/] [tkTabletcl.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
"proc tkTableClipboardKeysyms {copy cut paste} {\n"
2
"    bind Table <$copy> {tk_tableCopy %W}\n"
3
"    bind Table <$cut>  {tk_tableCut %W}\n"
4
"    bind Table <$paste>        {tk_tablePaste %W}\n"
5
"}\n"
6
"bind Table <3>         {\n"
7
"    ## You might want to check for row returned if you want to\n"
8
"    ## restrict the resizing of certain rows\n"
9
"    %W border mark %x %y\n"
10
"}\n"
11
"bind Table <B3-Motion> { %W border dragto %x %y }\n"
12
"bind Table <1> {\n"
13
"    if {[winfo exists %W]} {\n"
14
"       tkTableBeginSelect %W [%W index @%x,%y]\n"
15
"       focus %W\n"
16
"    }\n"
17
"}\n"
18
"bind Table <B1-Motion> {\n"
19
"    array set tkPriv {x %x y %y}\n"
20
"    tkTableMotion %W [%W index @%x,%y]\n"
21
"}\n"
22
"bind Table <Double-1> {\n"
23
"    # empty\n"
24
"}\n"
25
"bind Table <ButtonRelease-1> {\n"
26
"    if {[winfo exists %W]} {\n"
27
"       tkCancelRepeat\n"
28
"       %W activate @%x,%y\n"
29
"    }\n"
30
"}\n"
31
"bind Table <Shift-1>   {tkTableBeginExtend %W [%W index @%x,%y]}\n"
32
"bind Table <Control-1> {tkTableBeginToggle %W [%W index @%x,%y]}\n"
33
"bind Table <B1-Enter>  {tkCancelRepeat}\n"
34
"bind Table <B1-Leave>  {\n"
35
"    array set tkPriv {x %x y %y}\n"
36
"    tkTableAutoScan %W\n"
37
"}\n"
38
"bind Table <2> {\n"
39
"    %W scan mark %x %y\n"
40
"    array set tkPriv {x %x y %y}\n"
41
"    set tkPriv(mouseMoved) 0\n"
42
"}\n"
43
"bind Table <B2-Motion> {\n"
44
"    if {(%x != $tkPriv(x)) || (%y != $tkPriv(y))} { set tkPriv(mouseMoved) 1 }\n"
45
"    if $tkPriv(mouseMoved) { %W scan dragto %x %y }\n"
46
"}\n"
47
"bind Table <ButtonRelease-2> {\n"
48
"    if {!$tkPriv(mouseMoved)} { tk_tablePaste %W [%W index @%x,%y] }\n"
49
"}\n"
50
"if {[string comp {} [info command event]]} {\n"
51
"    tkTableClipboardKeysyms <Copy> <Cut> <Paste>\n"
52
"} else {\n"
53
"    tkTableClipboardKeysyms Control-c Control-x Control-v\n"
54
"}\n"
55
"bind Table <Any-Tab> {\n"
56
"    # empty to allow Tk focus movement\n"
57
"}\n"
58
"bind Table <FocusOut> {\n"
59
"    catch {%W activate active}\n"
60
"}\n"
61
"bind Table <Shift-Up>          {tkTableExtendSelect %W -1  0}\n"
62
"bind Table <Shift-Down>                {tkTableExtendSelect %W  1  0}\n"
63
"bind Table <Shift-Left>                {tkTableExtendSelect %W  0 -1}\n"
64
"bind Table <Shift-Right>       {tkTableExtendSelect %W  0  1}\n"
65
"bind Table <Prior>             {%W yview scroll -1 pages; %W activate @0,0}\n"
66
"bind Table <Next>              {%W yview scroll  1 pages; %W activate @0,0}\n"
67
"bind Table <Control-Prior>     {%W xview scroll -1 pages}\n"
68
"bind Table <Control-Next>      {%W xview scroll  1 pages}\n"
69
"bind Table <Home>              {%W see origin}\n"
70
"bind Table <End>               {%W see end}\n"
71
"bind Table <Control-Home> {\n"
72
"    %W selection clear all\n"
73
"    %W activate origin\n"
74
"    %W selection set active\n"
75
"    %W see active\n"
76
"}\n"
77
"bind Table <Control-End> {\n"
78
"    %W selection clear all\n"
79
"    %W activate end\n"
80
"    %W selection set active\n"
81
"    %W see active\n"
82
"}\n"
83
"bind Table <Shift-Control-Home>        {tkTableDataExtend %W origin}\n"
84
"bind Table <Shift-Control-End> {tkTableDataExtend %W end}\n"
85
"bind Table <Select>            {tkTableBeginSelect %W [%W index active]}\n"
86
"bind Table <Shift-Select>      {tkTableBeginExtend %W [%W index active]}\n"
87
"bind Table <Control-slash>     {tkTableSelectAll %W}\n"
88
"bind Table <Control-backslash> {\n"
89
"    if {[string match browse [%W cget -selectmode]]} {%W selection clear all}\n"
90
"}\n"
91
"bind Table <Up>                        {tkTableMoveCell %W -1  0}\n"
92
"bind Table <Down>              {tkTableMoveCell %W  1  0}\n"
93
"bind Table <Left>              {tkTableMoveCell %W  0 -1}\n"
94
"bind Table <Right>             {tkTableMoveCell %W  0  1}\n"
95
"bind Table <Any-KeyPress> {\n"
96
"    if {[string compare {} %A]} { %W insert active insert %A }\n"
97
"}\n"
98
"bind Table <BackSpace> {\n"
99
"    set tkPriv(junk) [%W icursor]\n"
100
"    if {[string compare {} $tkPriv(junk)] && $tkPriv(junk)} {\n"
101
"       %W delete active [expr {$tkPriv(junk)-1}]\n"
102
"    }\n"
103
"}\n"
104
"bind Table <Delete>            {%W delete active insert}\n"
105
"bind Table <Escape>            {%W reread}\n"
106
"bind Table <Return> {\n"
107
"    %W insert active insert \"\n\"\n"
108
"}\n"
109
"bind Table <Control-Left>      {%W icursor [expr {[%W icursor]-1}]}\n"
110
"bind Table <Control-Right>     {%W icursor [expr {[%W icursor]+1}]}\n"
111
"bind Table <Control-e>         {%W icursor end}\n"
112
"bind Table <Control-a>         {%W icursor 0}\n"
113
"bind Table <Control-k>         {%W delete active insert end}\n"
114
"bind Table <Control-equal>     {tkTableChangeWidth %W active  1}\n"
115
"bind Table <Control-minus>     {tkTableChangeWidth %W active -1}\n"
116
"proc tkTableBeginSelect {w el} {\n"
117
"    global tkPriv\n"
118
"    if {[scan $el %d,%d r c] != 2} return\n"
119
"    switch [$w cget -selectmode] {\n"
120
"       multiple {\n"
121
"           if {[$w tag includes title $el]} {\n"
122
"               ## in the title area\n"
123
"               if {$r < [$w cget -titlerows]+[$w cget -roworigin]} {\n"
124
"                   ## We're in a column header\n"
125
"                   if {$c < [$w cget -titlecols]+[$w cget -colorigin]} {\n"
126
"                       ## We're in the topleft title area\n"
127
"                       set inc topleft\n"
128
"                       set el2 end\n"
129
"                   } else {\n"
130
"                       set inc [$w index topleft row],$c\n"
131
"                       set el2 [$w index end row],$c\n"
132
"                   }\n"
133
"               } else {\n"
134
"                   ## We're in a row header\n"
135
"                   set inc $r,[$w index topleft col]\n"
136
"                   set el2 $r,[$w index end col]\n"
137
"               }\n"
138
"           } else {\n"
139
"               set inc $el\n"
140
"               set el2 $el\n"
141
"           }\n"
142
"           if [$w selection includes $inc] {\n"
143
"               $w selection clear $el $el2\n"
144
"           } else {\n"
145
"               $w selection set $el $el2\n"
146
"           }\n"
147
"       }\n"
148
"       extended {\n"
149
"           $w selection clear all\n"
150
"           if {[$w tag includes title $el]} {\n"
151
"               if {$r < [$w cget -titlerows]+[$w cget -roworigin]} {\n"
152
"                   ## We're in a column header\n"
153
"                   if {$c < [$w cget -titlecols]+[$w cget -colorigin]} {\n"
154
"                       $w selection set origin end\n"
155
"                   } else {\n"
156
"                       $w selection set $el [$w index end row],$c\n"
157
"                   }\n"
158
"               } else {\n"
159
"                   ## We're in a row header\n"
160
"                   $w selection set $el $r,[$w index end col]\n"
161
"               }\n"
162
"           } else {\n"
163
"               $w selection set $el\n"
164
"           }\n"
165
"           $w selection anchor $el\n"
166
"           set tkPriv(tablePrev) $el\n"
167
"       }\n"
168
"       default {\n"
169
"           if {![$w tag includes title $el]} {\n"
170
"               $w selection clear all\n"
171
"               $w selection set $el\n"
172
"               set tkPriv(tablePrev) $el\n"
173
"           }\n"
174
"           $w selection anchor $el\n"
175
"       }\n"
176
"    }\n"
177
"}\n"
178
"proc tkTableMotion {w el} {\n"
179
"    global tkPriv\n"
180
"    if {![info exists tkPriv(tablePrev)]} {\n"
181
"       set tkPriv(tablePrev) $el\n"
182
"       return\n"
183
"    }\n"
184
"    if {[string match $tkPriv(tablePrev) $el]} return\n"
185
"    switch [$w cget -selectmode] {\n"
186
"       browse {\n"
187
"           $w selection clear all\n"
188
"           $w selection set $el\n"
189
"           set tkPriv(tablePrev) $el\n"
190
"       }\n"
191
"       extended {\n"
192
"           scan $tkPriv(tablePrev) %d,%d r c\n"
193
"           scan $el %d,%d elr elc\n"
194
"           if {[$w tag includes title $el]} {\n"
195
"               if {$r < [$w cget -titlerows]+[$w cget -roworigin]} {\n"
196
"                   ## We're in a column header\n"
197
"                   if {$c < [$w cget -titlecols]+[$w cget -colorigin]} {\n"
198
"                       ## We're in the topleft title area\n"
199
"                       $w selection clear anchor end\n"
200
"                   } else {\n"
201
"                       $w selection clear anchor [$w index end row],$c\n"
202
"                   }\n"
203
"                   $w selection set anchor [$w index end row],$elc\n"
204
"               } else {\n"
205
"                   ## We're in a row header\n"
206
"                   $w selection clear anchor $r,[$w index end col]\n"
207
"                   $w selection set anchor $elr,[$w index end col]\n"
208
"               }\n"
209
"           } else {\n"
210
"               $w selection clear anchor $tkPriv(tablePrev)\n"
211
"               $w selection set anchor $el\n"
212
"           }\n"
213
"           set tkPriv(tablePrev) $el\n"
214
"       }\n"
215
"    }\n"
216
"}\n"
217
"proc tkTableBeginExtend {w el} {\n"
218
"    if {[string match extended [$w cget -selectmode]] &&\n"
219
"       [$w selection includes anchor]} {\n"
220
"       tkTableMotion $w $el\n"
221
"    }\n"
222
"}\n"
223
"proc tkTableBeginToggle {w el} {\n"
224
"    global tkPriv\n"
225
"    if {[string match extended [$w cget -selectmode]]} {\n"
226
"       set tkPriv(tablePrev) $el\n"
227
"       $w selection anchor $el\n"
228
"       if [$w selection includes $el] {\n"
229
"           $w selection clear $el\n"
230
"       } else {\n"
231
"           $w selection set $el\n"
232
"       }\n"
233
"    }\n"
234
"}\n"
235
"proc tkTableAutoScan {w} {\n"
236
"    global tkPriv\n"
237
"    if {![winfo exists $w]} return\n"
238
"    set x $tkPriv(x)\n"
239
"    set y $tkPriv(y)\n"
240
"    if {$y >= [winfo height $w]} {\n"
241
"       $w yview scroll 1 units\n"
242
"    } elseif {$y < 0} {\n"
243
"       $w yview scroll -1 units\n"
244
"    } elseif {$x >= [winfo width $w]} {\n"
245
"       $w xview scroll 1 units\n"
246
"    } elseif {$x < 0} {\n"
247
"       $w xview scroll -1 units\n"
248
"    } else {\n"
249
"       return\n"
250
"    }\n"
251
"    tkTableMotion $w [$w index @$x,$y]\n"
252
"    set tkPriv(afterId) [after 50 tkTableAutoScan $w]\n"
253
"}\n"
254
"proc tkTableMoveCell {w x y} {\n"
255
"    global tkPriv\n"
256
"    if {[catch {$w index active row} r]} return\n"
257
"    set c [$w index active col]\n"
258
"    $w activate [incr r $x],[incr c $y]\n"
259
"    $w see active\n"
260
"    switch [$w cget -selectmode] {\n"
261
"       browse {\n"
262
"           $w selection clear all\n"
263
"           $w selection set active\n"
264
"       }\n"
265
"       extended {\n"
266
"           $w selection clear all\n"
267
"           $w selection set active\n"
268
"           $w selection anchor active\n"
269
"           set tkPriv(tablePrev) [$w index active]\n"
270
"       }\n"
271
"    }\n"
272
"}\n"
273
"proc tkTableExtendSelect {w x y} {\n"
274
"    if {[string compare extended [$w cget -selectmode]] ||\n"
275
"       [catch {$w index active row} r]} return\n"
276
"    set c [$w index active col]\n"
277
"    $w activate [incr r $x],[incr c $y]\n"
278
"    $w see active\n"
279
"    tkTableMotion $w [$w index active]\n"
280
"}\n"
281
"proc tkTableDataExtend {w el} {\n"
282
"    set mode [$w cget -selectmode]\n"
283
"    if {[string match extended $mode]} {\n"
284
"       $w activate $el\n"
285
"       $w see $el\n"
286
"       if [$w selection includes anchor] {tkTableMotion $w $el}\n"
287
"    } elseif {[string match multiple $mode]} {\n"
288
"       $w activate $el\n"
289
"       $w see $el\n"
290
"    }\n"
291
"}\n"
292
"proc tkTableSelectAll {w} {\n"
293
"    if {[regexp {^(single|browse)$} [$w cget -selectmode]]} {\n"
294
"       $w selection clear all\n"
295
"       $w selection set active\n"
296
"       tkTableHandleType $w [$w index active]\n"
297
"    } else {\n"
298
"       $w selection set origin end\n"
299
"    }\n"
300
"}\n"
301
"proc tkTableChangeWidth {w i a} {\n"
302
"    set tmp [$w index $i col]\n"
303
"    if {[set width [$w width $tmp]] >= 0} {\n"
304
"       $w width $tmp [incr width $a]\n"
305
"    } else {\n"
306
"       $w width $tmp [incr width -$a]\n"
307
"    }\n"
308
"}\n"
309
"proc tk_tableCopy w {\n"
310
"    if {[selection own -displayof $w] == \"$w\"} {\n"
311
"       clipboard clear -displayof $w\n"
312
"       catch {clipboard append -displayof $w [selection get -displayof $w]}\n"
313
"    }\n"
314
"}\n"
315
"proc tk_tableCut w {\n"
316
"    if {[selection own -displayof $w] == \"$w\"} {\n"
317
"       clipboard clear -displayof $w\n"
318
"       catch {\n"
319
"           clipboard append -displayof $w [selection get -displayof $w]\n"
320
"           $w cursel set {}\n"
321
"           $w selection clear all\n"
322
"       }\n"
323
"    }\n"
324
"}\n"
325
"proc tk_tablePaste {w {cell {}}} {\n"
326
"    if {[string compare {} $cell]} {\n"
327
"       if {[catch {selection get -displayof $w} data]} return\n"
328
"    } else {\n"
329
"       if {[catch {selection get -displayof $w -selection CLIPBOARD} data]} {\n"
330
"           return\n"
331
"       }\n"
332
"       set cell active\n"
333
"    }\n"
334
"    tk_tablePasteHandler $w [$w index $cell] $data\n"
335
"    if {[$w cget -state] == \"normal\"} {focus $w}\n"
336
"}\n"
337
"proc tk_tablePasteHandler {w cell data} {\n"
338
"    set rows   [expr {[$w cget -rows]-[$w cget -roworigin]}]\n"
339
"    set cols   [expr {[$w cget -cols]-[$w cget -colorigin]}]\n"
340
"    set r      [$w index $cell row]\n"
341
"    set c      [$w index $cell col]\n"
342
"    set rsep   [$w cget -rowseparator]\n"
343
"    set csep   [$w cget -colseparator]\n"
344
"    ## Assume separate rows are split by row separator if specified\n"
345
"    ## If you were to want multi-character row separators, you would need:\n"
346
"    # regsub -all $rsep $data <newline> data\n"
347
"    # set data [join $data <newline>]\n"
348
"    if {[string comp {} $rsep]} { set data [split $data $rsep] }\n"
349
"    set row    $r\n"
350
"    foreach line $data {\n"
351
"       if {$row > $rows} break\n"
352
"       set col $c\n"
353
"       ## Assume separate cols are split by col separator if specified\n"
354
"       ## Unless a -separator was specified\n"
355
"       if {[string comp {} $csep]} { set line [split $line $csep] }\n"
356
"       ## If you were to want multi-character col separators, you would need:\n"
357
"       # regsub -all $csep $line <newline> line\n"
358
"       # set line [join $line <newline>]\n"
359
"       foreach item $line {\n"
360
"           if {$col > $cols} break\n"
361
"           $w set $row,$col $item\n"
362
"           incr col\n"
363
"       }\n"
364
"       incr row\n"
365
"    }\n"
366
"}\n"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.