File: mypane.tcl

package info (click to toggle)
tkgate 2.1%2Brepack-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 28,384 kB
  • sloc: ansic: 62,300; tcl: 20,345; xml: 2,731; yacc: 1,177; lex: 839; sh: 664; makefile: 180; perl: 39
file content (123 lines) | stat: -rw-r--r-- 3,306 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#   Copyright (C) 1987-2015 by Jeffery P. Hansen
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License along
#   with this program; if not, write to the Free Software Foundation, Inc.,
#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Last edit by hansen on Thu Jan 22 08:45:53 2004
#

#############################################################################
#
# Panes are used to do resizing of two windows
#
#

namespace eval Pane {
  variable details
  variable grabpos

  proc resize {w x y} {
    variable details
    variable grabpos

    set variable [assoc variable $details($w) ]

    if {$variable == "vertical"} {
      set old_y [lindex $grabpos($w) 1]
      $w.p1 configure -height [expr [winfo height $w.p1] - ($old_y - $y)]

      set grabpos($w) [list $x $y]
    }

    puts resize
  }

  proc makeGrabber {parent w gwidth isVert} {
    variable grabpos

    set grabpos($w) {}

    if {$isVert} {
      set width 50
      set height 2
      frame $w -width $gwidth
    } else {
      set width 2
      set height 50
      frame $w -height $gwidth
    }

    bindtags $w pane$w
    bindtags $w.p1 pane$w
    bindtags $w.p2 pane$w
    bindtags $w.p3 pane$w
    bindtags $w.p4 pane$w
    bindtags $w.v1 pane$w
    bindtags $w.v2 pane$w
    bindtags $w.v3 pane$w

    if { $isVert } {
      pack $w.p1 -padx 1 -side left
      pack $w.p2 -padx 1 -side right
      pack $w.p3 -padx 0 -side top -fill both -expand 1
      pack $w.v1 -padx 0 -side top
      pack $w.v2 -padx 0 -side top
      pack $w.v3 -padx 0 -side top
      pack $w.p4 -padx 0 -side top -fill both -expand 1
    } else {
      pack $w.p1 -pady 1 -side top
      pack $w.p2 -pady 1 -side bottom
      pack $w.p3 -pady 0 -side left -fill both -expand 1
      pack $w.v1 -pady 0 -side left
      pack $w.v2 -pady 0 -side left
      pack $w.v3 -pady 0 -side left
      pack $w.p4 -pady 0 -side left -fill both -expand 1
    }

    bind pane$w <1> "set grabpos($w) {%X %Y}"
    bind pane$w <B1-Motion> "Pane::resize $parent %X %Y"
  }

  proc create {w args} {
    variable details

    set orientation vertical
    set width 175
    parseargs $args {-orientation -width}

    set details($w) {}
    lappend details($w) [list orientation $orientation]
    lappend details($w) [list width $width]

    if { $orientation ==  "vertical" } {
      frame $w
      frame $w.w1
      makeGrabber $w $w.grab $width 1
      frame $w.w2

      pack $w.w1 -fill both -expand 1
      pack $w.grab -ipady 4
      pack $w.w2 -fill both -expand 1
    } else {
      frame $w
      frame $w.w1
      makeGrabber $w $w.grab $width 0
      frame $w.w2

      pack $w.w1 -side left left -fill both -expand 1
      pack $w.grab -side left
      pack $w.w2 -side left -fill both -expand 1
    }
  }
}