(self, x, y)
| 200 | self.canvas['cursor'] = oldcursor |
| 201 | |
| 202 | def draw(self, x, y): |
| 203 | # XXX This hard-codes too many geometry constants! |
| 204 | self.x, self.y = x, y |
| 205 | self.drawicon() |
| 206 | self.drawtext() |
| 207 | if self.state != 'expanded': |
| 208 | return y + TreeNode.dy |
| 209 | # draw children |
| 210 | if not self.children: |
| 211 | sublist = self.item._GetSubList() |
| 212 | if not sublist: |
| 213 | # _IsExpandable() was mistaken; that's allowed |
| 214 | return y + TreeNode.dy |
| 215 | for item in sublist: |
| 216 | child = self.__class__(self.canvas, self, item) |
| 217 | self.children.append(child) |
| 218 | cx = x+20 |
| 219 | cy = y + TreeNode.dy |
| 220 | cylast = 0 |
| 221 | for child in self.children: |
| 222 | cylast = cy |
| 223 | self.canvas.create_line(x+9, cy+7, cx, cy+7, fill="gray50") |
| 224 | cy = child.draw(cx, cy) |
| 225 | if child.item._IsExpandable(): |
| 226 | if child.state == 'expanded': |
| 227 | iconname = "minusnode" |
| 228 | callback = child.collapse |
| 229 | else: |
| 230 | iconname = "plusnode" |
| 231 | callback = child.expand |
| 232 | image = self.geticonimage(iconname) |
| 233 | id = self.canvas.create_image(x+9, cylast+7, image=image) |
| 234 | # XXX This leaks bindings until canvas is deleted: |
| 235 | self.canvas.tag_bind(id, "<1>", callback) |
| 236 | self.canvas.tag_bind(id, "<Double-1>", lambda x: None) |
| 237 | id = self.canvas.create_line(x+9, y+10, x+9, cylast+7, |
| 238 | ##stipple="gray50", # XXX Seems broken in Tk 8.0.x |
| 239 | fill="gray50") |
| 240 | self.canvas.tag_lower(id) # XXX .lower(id) before Python 1.5.2 |
| 241 | return cy |
| 242 | |
| 243 | def drawicon(self): |
| 244 | if self.selected: |
no test coverage detected