14 |
from wxPython.wx import * |
from wxPython.wx import * |
15 |
|
|
16 |
from Thuban import _ |
from Thuban import _ |
17 |
|
from Thuban.UI.common import * |
18 |
|
|
19 |
from Thuban.Model.color import Color |
from Thuban.Model.color import Color |
20 |
|
|
23 |
from Thuban.Model.map import Map |
from Thuban.Model.map import Map |
24 |
|
|
25 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
26 |
from messages import SESSION_CHANGED, SELECTED_LAYER |
from messages import SESSION_REPLACED, SELECTED_LAYER |
27 |
|
|
28 |
BMP_SIZE = 15 |
BMP_SIZE = 15 |
29 |
|
|
62 |
# Dictionary mapping layer id's to tree items |
# Dictionary mapping layer id's to tree items |
63 |
self.layer_to_item = {} |
self.layer_to_item = {} |
64 |
|
|
65 |
self.app.Subscribe(SESSION_CHANGED, self.session_changed) |
self.app.Subscribe(SESSION_REPLACED, self.session_changed) |
66 |
self.app.interactor.Subscribe(SELECTED_LAYER, self.layer_selected) |
self.app.interactor.Subscribe(SELECTED_LAYER, self.layer_selected) |
67 |
|
|
68 |
# the session currently displayed in the tree |
# the session currently displayed in the tree |
80 |
if self.session is not None: |
if self.session is not None: |
81 |
self.session.Unsubscribe(CHANGED, self.update_tree) |
self.session.Unsubscribe(CHANGED, self.update_tree) |
82 |
self.session = None |
self.session = None |
83 |
self.app.Unsubscribe(SESSION_CHANGED, self.session_changed) |
self.app.Unsubscribe(SESSION_REPLACED, self.session_changed) |
84 |
self.app.interactor.Unsubscribe(SELECTED_LAYER, self.layer_selected) |
self.app.interactor.Unsubscribe(SELECTED_LAYER, self.layer_selected) |
85 |
|
|
86 |
def update_tree(self, *args): |
def update_tree(self, *args): |
107 |
self.SelectItem(item) |
self.SelectItem(item) |
108 |
|
|
109 |
def add_items(self, parent, items): |
def add_items(self, parent, items): |
|
# print "\n---\n", items |
|
110 |
|
|
111 |
if items is None: return |
if items is None: return |
112 |
|
|
127 |
else: |
else: |
128 |
# assume its a sequence (title, items) |
# assume its a sequence (title, items) |
129 |
if isinstance(item[1], Color): |
if isinstance(item[1], Color): |
130 |
treeitem = self.AppendItem(parent, _("(%s)") % item[0]) |
|
131 |
|
treeitem = self.AppendItem(parent, "(%s)" % item[0]) |
132 |
|
|
133 |
bmp = wxEmptyBitmap(BMP_SIZE, BMP_SIZE) |
bmp = wxEmptyBitmap(BMP_SIZE, BMP_SIZE) |
134 |
brush = wxBrush(wxColour(item[1].red * 255, |
brush = wxBrush(Color2wxColour(item[1]), wxSOLID) |
|
item[1].green * 255, |
|
|
item[1].blue * 255), |
|
|
wxSOLID) |
|
135 |
dc = wxMemoryDC() |
dc = wxMemoryDC() |
136 |
dc.SelectObject(bmp) |
dc.SelectObject(bmp) |
137 |
dc.SetBrush(brush) |
dc.SetBrush(brush) |
213 |
self.tree = SessionTreeCtrl(self, -1, app) |
self.tree = SessionTreeCtrl(self, -1, app) |
214 |
|
|
215 |
def OnClose(self, event): |
def OnClose(self, event): |
|
#self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape) |
|
216 |
NonModalDialog.OnClose(self, event) |
NonModalDialog.OnClose(self, event) |
217 |
|
|
218 |
# if there were a way to get notified when the tree control |
# if there were a way to get notified when the tree control |
220 |
# of doing it here. (EVT_WINDOW_DESTROY doesn't seem to sent at |
# of doing it here. (EVT_WINDOW_DESTROY doesn't seem to sent at |
221 |
# all) |
# all) |
222 |
self.tree.unsubscribe_all() |
self.tree.unsubscribe_all() |
223 |
|
|