|
#! /usr/bin/python |
|
1 |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Jan-Oliver Wagner <[email protected]> |
# Jan-Oliver Wagner <[email protected]> |
10 |
|
|
11 |
from types import StringType, UnicodeType |
from types import StringType, UnicodeType |
12 |
|
|
13 |
from wxPython.wx import * |
import wx |
14 |
|
|
15 |
from Thuban import _ |
from Thuban import _ |
16 |
from Thuban.UI.common import Color2wxColour |
from Thuban.UI.common import Color2wxColour |
26 |
|
|
27 |
BMP_SIZE = 15 |
BMP_SIZE = 15 |
28 |
|
|
29 |
class SessionTreeCtrl(wxTreeCtrl): |
class SessionTreeCtrl(wx.TreeCtrl): |
30 |
|
|
31 |
"""Widget to display a tree view of the session. |
"""Widget to display a tree view of the session. |
32 |
|
|
51 |
def __init__(self, parent, ID, mainwindow, app): |
def __init__(self, parent, ID, mainwindow, app): |
52 |
|
|
53 |
# Use the WANTS_CHARS style so the panel doesn't eat the Return key. |
# Use the WANTS_CHARS style so the panel doesn't eat the Return key. |
54 |
wxTreeCtrl.__init__(self, parent, ID) |
wx.TreeCtrl.__init__(self, parent, ID) |
55 |
|
|
56 |
self.mainwindow = mainwindow |
self.mainwindow = mainwindow |
57 |
self.app = app |
self.app = app |
72 |
# pretend the session has changed to build the initial tree |
# pretend the session has changed to build the initial tree |
73 |
self.session_changed() |
self.session_changed() |
74 |
|
|
75 |
EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged) |
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=self.GetId()) |
76 |
|
|
77 |
def unsubscribe_all(self): |
def unsubscribe_all(self): |
78 |
if self.session is not None: |
if self.session is not None: |
85 |
"""Clear and rebuild the tree""" |
"""Clear and rebuild the tree""" |
86 |
self.DeleteAllItems() |
self.DeleteAllItems() |
87 |
self.layer_to_item.clear() |
self.layer_to_item.clear() |
88 |
self.image_list = wxImageList(BMP_SIZE, BMP_SIZE, False, 0) |
self.image_list = wx.ImageList(BMP_SIZE, BMP_SIZE, False, 0) |
89 |
|
|
90 |
bmp = wxEmptyBitmap(BMP_SIZE, BMP_SIZE) |
bmp = wx.EmptyBitmap(BMP_SIZE, BMP_SIZE) |
91 |
dc = wxMemoryDC() |
dc = wx.MemoryDC() |
92 |
dc.SelectObject(bmp) |
dc.SelectObject(bmp) |
93 |
dc.SetBrush(wxBLACK_BRUSH) |
dc.SetBrush(wx.BLACK_BRUSH) |
94 |
dc.Clear() |
dc.Clear() |
95 |
dc.SelectObject(wxNullBitmap) |
dc.SelectObject(wx.NullBitmap) |
96 |
|
|
97 |
self.emptyImageIndex = \ |
self.emptyImageIndex = \ |
98 |
self.image_list.AddWithColourMask(bmp, wxColour(0, 0, 0)) |
self.image_list.AddWithColourMask(bmp, wx.Colour(0, 0, 0)) |
99 |
|
|
100 |
self.AssignImageList(self.image_list) |
self.AssignImageList(self.image_list) |
101 |
|
|
144 |
|
|
145 |
treeitem = self.AppendItem(parent, "(%s)" % item[0]) |
treeitem = self.AppendItem(parent, "(%s)" % item[0]) |
146 |
|
|
147 |
bmp = wxEmptyBitmap(BMP_SIZE, BMP_SIZE) |
bmp = wx.EmptyBitmap(BMP_SIZE, BMP_SIZE) |
148 |
brush = wxBrush(Color2wxColour(item[1]), wxSOLID) |
brush = wx.Brush(Color2wxColour(item[1]), wx.SOLID) |
149 |
dc = wxMemoryDC() |
dc = wx.MemoryDC() |
150 |
dc.SelectObject(bmp) |
dc.SelectObject(bmp) |
151 |
dc.SetBrush(brush) |
dc.SetBrush(brush) |
152 |
dc.Clear() |
dc.Clear() |
153 |
dc.DrawRoundedRectangle(0, 0, |
dc.DrawRoundedRectangle(0, 0, |
154 |
bmp.GetWidth(), bmp.GetHeight(), |
bmp.GetWidth(), bmp.GetHeight(), |
155 |
4) |
4) |
156 |
dc.SelectObject(wxNullBitmap) |
dc.SelectObject(wx.NullBitmap) |
157 |
|
|
158 |
i = self.image_list.Add(bmp) |
i = self.image_list.Add(bmp) |
159 |
self.SetItemImage(treeitem, i) |
self.SetItemImage(treeitem, i) |