File: BaseWBCanvas.itcl

package info (click to toggle)
coccinella 0.96.20-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,108 kB
  • ctags: 5,908
  • sloc: tcl: 124,744; xml: 206; makefile: 66; sh: 62
file content (184 lines) | stat: -rw-r--r-- 4,751 bytes parent folder | download | duplicates (4)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# BaseWBCanvas.itcl 
# 
#       Interface between application code and the itcl runtime environment for
#       tcl applets.
#       
#       An itcl applet inherits this class which makes a number of methods
#       available from the actual application code.
#       
#       To be safe the code should run in a safe interpreter with all
#       methods and variables in this base class aliased.
# 
#  Copyright (c) 2007 Mats Bengtsson
#  
#   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 3 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, see <http://www.gnu.org/licenses/>.
#   
# $Id: BaseWBCanvas.itcl,v 1.6 2007-07-19 06:28:18 matben Exp $

class BaseWBCanvas {
	
    # ------------------
    # Class constructor.
    # ------------------

    protected {
	constructor {args} {}
	destructor {}
    }

    # ------------------------
    # Protected class methods.
    # ------------------------

    protected {
	method NewUtag {}
	method GetUtag {id}
	method NewImportAnchor
	method RegisterCanvasClassBinds {name canvasBindList}
	method DeregisterCanvasClassBinds {name}
	method RegisterCanvasInstBinds {name canvasBindList}
	method DeregisterCanvasInstBinds {{name {}}}
	method CancelBox {}
	method CreateItem {args}
	method ItemConfigure {id args}
	method InitMoveCurrent {x y}
	method DragMoveCurrent {x y {modifier {}}}
	method FinalMoveCurrent {x y}
	method FinalMoveCurrentGrid {x y grid}
	method AddUndo {undo redo}
	method DeleteCurrent {}
	method AddGarbageImages {name args}
	method Command {cmd {where all}}
	method CommandList {cmdList {where all}}
	method GenCommand {cmd {where all}}
    }

    # -------------------------
    # Protected static methods.
    # -------------------------

    protected {
	proc GetThis {key}
    }
    
    # ---------------------------
    # Private class data members.
    # ---------------------------
    
    protected {
	variable tkCanvas
    }
}

body BaseWBCanvas::constructor {args} {
    
    if {[llength $args] != 1} {
	return
    }
    set w [lindex $args 0]
    set tkCanvas $w
}

body BaseWBCanvas::destructor {} {

}

body BaseWBCanvas::NewUtag {} {
    return [::CanvasUtils::NewUtag]
}

body BaseWBCanvas::NewImportAnchor {} {
    return [::CanvasUtils::NewImportAnchor $tkCanvas]
}

body BaseWBCanvas::RegisterCanvasClassBinds {name canvasBindList} {
    ::WB::RegisterCanvasClassBinds $name $canvasBindList
}

body BaseWBCanvas::RegisterCanvasInstBinds {name canvasBindList} {
    ::WB::RegisterCanvasInstBinds $tkCanvas $name $canvasBindList
}

body BaseWBCanvas::DeregisterCanvasInstBinds {{name {}}} {
    ::Plugins::DeregisterCanvasInstBinds $tkCanvas $name
}

body BaseWBCanvas::CancelBox {} {
    ::CanvasDraw::CancelBox $tkCanvas
}

body BaseWBCanvas::CreateItem {args} {
    eval {::CanvasUtils::CreateItem $tkCanvas} $args
}

body BaseWBCanvas::ItemConfigure {id args} {
    eval {::CanvasUtils::ItemConfigure $tkCanvas $id} $args
}

body BaseWBCanvas::GetUtag {id} {
    return [::CanvasUtils::GetUtag $tkCanvas $id]
}

body BaseWBCanvas::GetThis {key} {
    global  this    
    return $this($key)
}

body BaseWBCanvas::InitMoveCurrent {x y} {
    ::CanvasDraw::InitMoveCurrent $tkCanvas $x $y
}

body BaseWBCanvas::DragMoveCurrent {x y {modifier {}}} {
    ::CanvasDraw::DragMoveCurrent $tkCanvas $x $y $modifier
}

body BaseWBCanvas::FinalMoveCurrent {x y} {   
    ::CanvasDraw::FinalMoveCurrent $tkCanvas $x $y
}

body BaseWBCanvas::FinalMoveCurrentGrid {x y grid} {   
    ::CanvasDraw::FinalMoveCurrentGrid $tkCanvas $x $y $grid
}

body BaseWBCanvas::AddUndo {undo redo} {
    undo::add [::WB::GetUndoToken $tkCanvas] $undo $redo
}

body BaseWBCanvas::DeleteCurrent {} {
    ::CanvasDraw::DeleteCurrent $tkCanvas
}

body BaseWBCanvas::AddGarbageImages {name args} {
    eval {::CanvasDraw::AddGarbageImages $name} $args
}

body BaseWBCanvas::Command {cmd {where all}} {
    set w [winfo toplevel $tkCanvas]
    ::CanvasUtils::Command $w $cmd $where
}

body BaseWBCanvas::CommandList {cmdList {where all}} {
    set w [winfo toplevel $tkCanvas]
    ::CanvasUtils::CommandList $w $cmdList $where
}

body BaseWBCanvas::GenCommand {cmd {where all}} {
    set w [winfo toplevel $tkCanvas]
    ::CanvasUtils::GenCommand $w $cmd $where
}