1 |
jonathan |
542 |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
|
|
# Authors: |
3 |
|
|
# Jonathan Coles <[email protected]> |
4 |
|
|
# |
5 |
|
|
# This program is free software under the GPL (>=v2) |
6 |
|
|
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
|
8 |
|
|
__version__ = "$Revision$" |
9 |
|
|
|
10 |
|
|
from Thuban import _ |
11 |
|
|
|
12 |
jonathan |
652 |
import resource |
13 |
|
|
|
14 |
jonathan |
542 |
from wxPython.wx import * |
15 |
|
|
|
16 |
|
|
from Thuban.Model.layer import Layer |
17 |
|
|
from Thuban.Model.map import Map |
18 |
|
|
from Thuban.Model.messages import * |
19 |
|
|
from Thuban.Model.classification import ClassGroup |
20 |
|
|
|
21 |
jonathan |
572 |
from Thuban.UI.messages import * |
22 |
jonathan |
542 |
from Thuban.UI.classifier import ClassDataPreviewer |
23 |
jonathan |
562 |
from Thuban.UI.dock import DockPanel |
24 |
jonathan |
542 |
|
25 |
jonathan |
572 |
from Thuban.Lib.connector import ConnectorError |
26 |
|
|
|
27 |
jonathan |
652 |
ID_LEGEND_RAISE = 4001 |
28 |
|
|
ID_LEGEND_LOWER = 4002 |
29 |
jonathan |
542 |
ID_LEGEND_TREE = 4003 |
30 |
jonathan |
639 |
ID_LEGEND_PROPS = 4004 |
31 |
jonathan |
542 |
ID_LEGEND_SHOWLAYER = 4005 |
32 |
|
|
ID_LEGEND_HIDELAYER = 4006 |
33 |
|
|
|
34 |
|
|
BMP_SIZE_W = 30 |
35 |
|
|
BMP_SIZE_H = 15 |
36 |
|
|
|
37 |
jonathan |
652 |
RAISE_BMP = "raise_layer" |
38 |
|
|
LOWER_BMP = "lower_layer" |
39 |
|
|
SHOW_BMP = "show_layer" |
40 |
|
|
HIDE_BMP = "hide_layer" |
41 |
|
|
PROPS_BMP = "layer_properties" |
42 |
|
|
|
43 |
|
|
|
44 |
jonathan |
562 |
class LegendPanel(DockPanel): |
45 |
|
|
|
46 |
|
|
def __init__(self, parent, map, mainWindow): |
47 |
|
|
DockPanel.__init__(self, parent, -1) |
48 |
|
|
|
49 |
|
|
self.mainWindow = mainWindow |
50 |
|
|
self.parent = parent |
51 |
|
|
|
52 |
jonathan |
652 |
self.buttons = [] |
53 |
|
|
|
54 |
jonathan |
542 |
panelBox = wxBoxSizer(wxVERTICAL) |
55 |
|
|
|
56 |
jonathan |
652 |
self.toolBar = wxToolBar(self, -1) |
57 |
jonathan |
542 |
|
58 |
jonathan |
652 |
bmp = resource.GetBitmapResource(RAISE_BMP, wxBITMAP_TYPE_XPM) |
59 |
|
|
self.toolBar.AddTool(ID_LEGEND_RAISE, bmp, |
60 |
|
|
shortHelpString=_("Raise Layer")) |
61 |
jonathan |
542 |
|
62 |
jonathan |
652 |
bmp = resource.GetBitmapResource(LOWER_BMP, wxBITMAP_TYPE_XPM) |
63 |
|
|
self.toolBar.AddTool(ID_LEGEND_LOWER, bmp, |
64 |
|
|
shortHelpString=_("Lower Layer")) |
65 |
jonathan |
542 |
|
66 |
jonathan |
652 |
bmp = resource.GetBitmapResource(SHOW_BMP, wxBITMAP_TYPE_XPM) |
67 |
|
|
self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp, |
68 |
|
|
shortHelpString=_("Show Layer")) |
69 |
jonathan |
542 |
|
70 |
jonathan |
652 |
bmp = resource.GetBitmapResource(HIDE_BMP, wxBITMAP_TYPE_XPM) |
71 |
|
|
self.toolBar.AddTool(ID_LEGEND_HIDELAYER, bmp, |
72 |
|
|
shortHelpString=_("Hide Layer")) |
73 |
jonathan |
542 |
|
74 |
jonathan |
652 |
bmp = resource.GetBitmapResource(PROPS_BMP, wxBITMAP_TYPE_XPM) |
75 |
|
|
self.toolBar.AddTool(ID_LEGEND_PROPS, bmp, |
76 |
|
|
shortHelpString=_("Edit Layer Properties")) |
77 |
jonathan |
542 |
|
78 |
jonathan |
652 |
self.toolBar.Realize() |
79 |
|
|
panelBox.Add(self.toolBar, 0, wxALL, 0) |
80 |
jonathan |
542 |
|
81 |
jonathan |
652 |
EVT_TOOL(self, ID_LEGEND_RAISE, self._OnMoveUp) |
82 |
|
|
EVT_TOOL(self, ID_LEGEND_LOWER, self._OnMoveDown) |
83 |
|
|
EVT_TOOL(self, ID_LEGEND_PROPS, self._OnProperties) |
84 |
|
|
EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer) |
85 |
|
|
EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer) |
86 |
jonathan |
542 |
|
87 |
jonathan |
562 |
self.tree = LegendTree(self, ID_LEGEND_TREE, map, mainWindow) |
88 |
jonathan |
542 |
|
89 |
|
|
panelBox.Add(self.tree, 1, wxGROW, 4) |
90 |
|
|
|
91 |
jonathan |
572 |
panelBox.Fit(self) |
92 |
|
|
|
93 |
jonathan |
562 |
self.SetAutoLayout(True) |
94 |
|
|
self.SetSizer(panelBox) |
95 |
jonathan |
542 |
panelBox.SetSizeHints(self) |
96 |
|
|
|
97 |
jonathan |
562 |
self.panelBox = panelBox |
98 |
jonathan |
542 |
|
99 |
jonathan |
652 |
self.__EnableButtons(False) |
100 |
|
|
|
101 |
jonathan |
572 |
EVT_CLOSE(self, self._OnClose) |
102 |
|
|
|
103 |
|
|
|
104 |
jonathan |
562 |
def GetMap(self): |
105 |
|
|
return self.tree.GetMap() |
106 |
|
|
|
107 |
|
|
def SetMap(self, map): |
108 |
|
|
self.tree.SetMap(map) |
109 |
|
|
|
110 |
jonathan |
572 |
def DoOnSelChanged(self, layer, group): |
111 |
jonathan |
542 |
|
112 |
jonathan |
572 |
ok = isinstance(layer, Layer) |
113 |
|
|
self.__EnableButtons(ok) |
114 |
|
|
|
115 |
|
|
if ok: |
116 |
jonathan |
568 |
self.mainWindow.SelectLayer(layer) |
117 |
|
|
|
118 |
jonathan |
639 |
def DoOnProperties(self): |
119 |
jonathan |
572 |
list = self.tree.GetSelectedHierarchy() |
120 |
|
|
|
121 |
|
|
ok = isinstance(list[0], Layer) |
122 |
|
|
if ok: |
123 |
jonathan |
639 |
self.mainWindow.OpenLayerProperties(list[0], list[1]) |
124 |
jonathan |
572 |
|
125 |
jonathan |
578 |
def Destroy(self): |
126 |
|
|
self.__Close() |
127 |
|
|
|
128 |
jonathan |
639 |
def _OnProperties(self, event): |
129 |
|
|
self.DoOnProperties() |
130 |
jonathan |
542 |
|
131 |
|
|
def _OnMoveUp(self, event): |
132 |
|
|
self.tree.MoveCurrentItemUp() |
133 |
|
|
|
134 |
|
|
def _OnMoveDown(self, event): |
135 |
|
|
self.tree.MoveCurrentItemDown() |
136 |
|
|
|
137 |
|
|
def _OnShowLayer(self, event): |
138 |
|
|
self.tree.DoOnShowLayer() |
139 |
|
|
pass |
140 |
|
|
|
141 |
jonathan |
578 |
#def Close(self, force = False): |
142 |
|
|
#DockPanel.Close(self, force) |
143 |
|
|
|
144 |
jonathan |
572 |
def _OnClose(self, event): |
145 |
jonathan |
578 |
self.__Close() |
146 |
jonathan |
572 |
|
147 |
jonathan |
542 |
def _OnHideLayer(self, event): |
148 |
|
|
self.tree.DoOnHideLayer() |
149 |
|
|
pass |
150 |
|
|
|
151 |
|
|
def __EnableButtons(self, on): |
152 |
jonathan |
652 |
self.toolBar.EnableTool(ID_LEGEND_RAISE, on) |
153 |
|
|
self.toolBar.EnableTool(ID_LEGEND_LOWER, on) |
154 |
|
|
self.toolBar.EnableTool(ID_LEGEND_SHOWLAYER, on) |
155 |
|
|
self.toolBar.EnableTool(ID_LEGEND_HIDELAYER, on) |
156 |
|
|
self.toolBar.EnableTool(ID_LEGEND_PROPS, on) |
157 |
jonathan |
542 |
|
158 |
jonathan |
578 |
def __Close(self): |
159 |
|
|
self.tree.Close() |
160 |
|
|
|
161 |
jonathan |
542 |
class LegendTree(wxTreeCtrl): |
162 |
|
|
|
163 |
jonathan |
562 |
def __init__(self, parent, id, map, mainWindow): |
164 |
jonathan |
542 |
wxTreeCtrl.__init__(self, parent, id, |
165 |
|
|
style = wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT, |
166 |
|
|
size = (200, 200)) |
167 |
|
|
|
168 |
jonathan |
572 |
self.mainWindow = mainWindow |
169 |
jonathan |
562 |
self.map = None |
170 |
jonathan |
542 |
self.parent = parent |
171 |
jonathan |
572 |
self.layer2id = {} |
172 |
jonathan |
542 |
|
173 |
|
|
self.image_list = None |
174 |
|
|
self.emptyImageIndex = 0 |
175 |
|
|
|
176 |
|
|
self.previewer = ClassDataPreviewer() |
177 |
|
|
|
178 |
|
|
EVT_TREE_ITEM_ACTIVATED(self, ID_LEGEND_TREE, self._OnItemActivated) |
179 |
|
|
EVT_TREE_SEL_CHANGED(self, ID_LEGEND_TREE, self._OnSelChanged) |
180 |
|
|
|
181 |
jonathan |
572 |
EVT_CLOSE(self, self._OnClose) |
182 |
|
|
|
183 |
jonathan |
562 |
self.SetMap(map) |
184 |
jonathan |
542 |
|
185 |
jonathan |
572 |
def _OnClose(self, event): |
186 |
|
|
self.SetMap(None) |
187 |
|
|
|
188 |
jonathan |
562 |
def GetMap(self): |
189 |
|
|
return self.map |
190 |
jonathan |
542 |
|
191 |
jonathan |
562 |
def SetMap(self, map): |
192 |
|
|
|
193 |
|
|
sub_list = [(MAP_STACKING_CHANGED, self._OnMsgMapStackingChanged), |
194 |
|
|
(MAP_LAYERS_ADDED, self._OnMsgMapLayersAddedRemoved), |
195 |
|
|
(MAP_LAYERS_REMOVED, self._OnMsgMapLayersAddedRemoved)] |
196 |
|
|
|
197 |
|
|
if self.map is not None: |
198 |
|
|
for msg, func in sub_list: self.map.Unsubscribe(msg, func) |
199 |
jonathan |
572 |
#self.mainWindow.application.Unsubscribe(SESSION_REPLACED, |
200 |
|
|
#self._OnMsgMapsChanged) |
201 |
|
|
#try: |
202 |
|
|
#self.mainWindow.application.session.Unsubscribe(MAPS_CHANGED, |
203 |
|
|
#self._OnMsgMapsChanged) |
204 |
|
|
#except ConnectorError: |
205 |
|
|
#pass |
206 |
jonathan |
562 |
self.__DeleteAllItems() |
207 |
|
|
|
208 |
|
|
self.map = map |
209 |
|
|
|
210 |
|
|
if self.map is not None: |
211 |
|
|
for msg, func in sub_list: self.map.Subscribe(msg, func) |
212 |
jonathan |
572 |
#self.mainWindow.application.session.Subscribe(MAPS_CHANGED, |
213 |
|
|
#self._OnMsgMapsChanged) |
214 |
|
|
#self.mainWindow.application.Subscribe(SESSION_REPLACED, |
215 |
|
|
#self._OnMsgMapsChanged) |
216 |
jonathan |
562 |
self.__FillTree(self.map) |
217 |
|
|
|
218 |
|
|
|
219 |
jonathan |
542 |
def MoveCurrentItemUp(self): |
220 |
|
|
cur_id = self.GetSelection() |
221 |
jonathan |
605 |
assert cur_id.IsOk() |
222 |
jonathan |
542 |
|
223 |
|
|
cur_data = self.GetPyData(cur_id) |
224 |
|
|
|
225 |
|
|
#prev_id = self.GetPrevSibling(cur_id) |
226 |
|
|
|
227 |
|
|
# |
228 |
|
|
# Get out if there's nowhere to go |
229 |
|
|
# |
230 |
|
|
#if prev_id == INVALID_TREE_ID: return |
231 |
|
|
|
232 |
|
|
if isinstance(cur_data, Layer): |
233 |
|
|
self.map.RaiseLayer(cur_data) |
234 |
|
|
elif isinstance(cur_data, ClassGroup): |
235 |
|
|
pass |
236 |
|
|
else: |
237 |
jonathan |
605 |
assert False, "Shouldn't be here." |
238 |
jonathan |
542 |
pass |
239 |
|
|
|
240 |
|
|
def MoveCurrentItemDown(self): |
241 |
|
|
cur_id = self.GetSelection() |
242 |
jonathan |
605 |
assert cur_id.IsOk() |
243 |
jonathan |
542 |
|
244 |
|
|
cur_data = self.GetPyData(cur_id) |
245 |
|
|
|
246 |
|
|
if isinstance(cur_data, Layer): |
247 |
|
|
self.map.LowerLayer(cur_data) |
248 |
|
|
elif isinstance(cur_data, ClassGroup): |
249 |
|
|
pass |
250 |
|
|
else: |
251 |
jonathan |
605 |
assert False, "Shouldn't be here." |
252 |
jonathan |
542 |
pass |
253 |
|
|
|
254 |
|
|
|
255 |
|
|
def OnCompareItems(self, item1, item2): |
256 |
|
|
|
257 |
|
|
data1 = self.GetPyData(item1) |
258 |
|
|
data2 = self.GetPyData(item2) |
259 |
|
|
|
260 |
|
|
if isinstance(data1, Layer): |
261 |
|
|
layers = self.map.Layers() |
262 |
|
|
return layers.index(data2) - layers.index(data1) |
263 |
|
|
else: |
264 |
|
|
return wxTreeCtrl.OnCompareItems(self, item1, item2) |
265 |
|
|
|
266 |
|
|
|
267 |
|
|
def DoOnShowLayer(self): |
268 |
jonathan |
572 |
#self.__ShowHideLayer(True) |
269 |
|
|
layer, group = self.GetSelectedHierarchy() |
270 |
|
|
layer.SetVisible(True) |
271 |
jonathan |
542 |
|
272 |
|
|
def DoOnHideLayer(self): |
273 |
jonathan |
572 |
#self.__ShowHideLayer(False) |
274 |
|
|
layer, group = self.GetSelectedHierarchy() |
275 |
|
|
layer.SetVisible(False) |
276 |
jonathan |
542 |
|
277 |
|
|
def Sort(self): |
278 |
|
|
self.SortChildren(self.GetRootItem()) |
279 |
|
|
|
280 |
jonathan |
572 |
def _OnMsgMapsChanged(self): |
281 |
jonathan |
639 |
#print self.map is self.mainWindow.Map() |
282 |
jonathan |
572 |
self.SetMap(self.mainWindow.Map()) |
283 |
|
|
|
284 |
jonathan |
542 |
def _OnSelChanged(self, event): |
285 |
|
|
|
286 |
jonathan |
572 |
layer, group = self.GetSelectedHierarchy() |
287 |
jonathan |
568 |
self.parent.DoOnSelChanged(layer, group) |
288 |
|
|
|
289 |
jonathan |
542 |
def _OnItemActivated(self, event): |
290 |
jonathan |
639 |
self.parent.DoOnProperties() |
291 |
jonathan |
542 |
|
292 |
|
|
def _OnMsgLayerChanged(self, layer): |
293 |
jonathan |
605 |
assert isinstance(layer, Layer) |
294 |
jonathan |
542 |
|
295 |
|
|
id = self.layer2id[layer] |
296 |
jonathan |
605 |
assert id.IsOk() |
297 |
jonathan |
542 |
|
298 |
jonathan |
578 |
# XXX: yikes! this is so bad, we should be doing what is |
299 |
|
|
# commented out, but there is a problem with keeping |
300 |
|
|
# track of the images in the image list when we replace |
301 |
|
|
# a layer. it ends up causing a seg fault. |
302 |
|
|
self.__FillTree(self.map) |
303 |
|
|
#self.__FillTreeLayer(id) |
304 |
jonathan |
542 |
|
305 |
|
|
def _OnMsgMapStackingChanged(self, *args): |
306 |
|
|
self.Sort() |
307 |
jonathan |
562 |
id = self.GetSelection() |
308 |
jonathan |
542 |
|
309 |
jonathan |
562 |
if id.IsOk(): |
310 |
|
|
self.EnsureVisible(id) |
311 |
|
|
|
312 |
|
|
def _OnMsgMapLayersAddedRemoved(self, map): |
313 |
jonathan |
605 |
assert map is self.map |
314 |
jonathan |
542 |
|
315 |
|
|
self.__FillTree(self.map) |
316 |
|
|
|
317 |
jonathan |
572 |
def _OnMsgLayerVisibilityChanged(self, layer): |
318 |
jonathan |
605 |
assert isinstance(layer, Layer) |
319 |
jonathan |
572 |
|
320 |
|
|
self.__ShowHideLayer(layer) |
321 |
|
|
|
322 |
jonathan |
652 |
def _OnMsgLayerTitleChanged(self, layer): |
323 |
|
|
|
324 |
|
|
id = self.layer2id[layer] |
325 |
|
|
if id.IsOk(): |
326 |
|
|
self.SetItemText(id, layer.Title()) |
327 |
|
|
|
328 |
jonathan |
572 |
def GetSelectedHierarchy(self): |
329 |
|
|
id = self.GetSelection() |
330 |
jonathan |
605 |
assert id.IsOk() |
331 |
jonathan |
572 |
|
332 |
|
|
layer = self.GetPyData(id) |
333 |
|
|
group = None |
334 |
|
|
|
335 |
|
|
if isinstance(layer, ClassGroup): |
336 |
|
|
id = self.GetItemParent(id) |
337 |
jonathan |
605 |
assert id.IsOk() |
338 |
jonathan |
572 |
group = layer |
339 |
|
|
layer = self.GetPyData(id) |
340 |
|
|
|
341 |
|
|
return (layer, group) |
342 |
|
|
|
343 |
jonathan |
542 |
def __FillTree(self, map): |
344 |
|
|
|
345 |
jonathan |
605 |
assert isinstance(map, Map) |
346 |
jonathan |
542 |
|
347 |
|
|
self.Freeze() |
348 |
|
|
|
349 |
|
|
self.__DeleteAllItems() |
350 |
|
|
|
351 |
|
|
if map.HasLayers(): |
352 |
|
|
|
353 |
|
|
self.image_list = wxImageList(BMP_SIZE_W, BMP_SIZE_H, False, 0) |
354 |
|
|
|
355 |
|
|
bmp = wxEmptyBitmap(BMP_SIZE_W, BMP_SIZE_H) |
356 |
|
|
dc = wxMemoryDC() |
357 |
|
|
dc.SelectObject(bmp) |
358 |
|
|
dc.SetBrush(wxBLACK_BRUSH) |
359 |
|
|
dc.Clear() |
360 |
|
|
dc.SelectObject(wxNullBitmap) |
361 |
|
|
|
362 |
|
|
self.emptyImageIndex = \ |
363 |
|
|
self.image_list.AddWithColourMask(bmp, wxColour(0, 0, 0)) |
364 |
|
|
|
365 |
|
|
self.AssignImageList(self.image_list) |
366 |
|
|
|
367 |
|
|
root = self.AddRoot("") |
368 |
|
|
|
369 |
|
|
for l in map.Layers(): |
370 |
|
|
id = self.PrependItem(root, l.Title()) |
371 |
|
|
l.Subscribe(LAYER_CHANGED, self._OnMsgLayerChanged) |
372 |
jonathan |
572 |
l.Subscribe(LAYER_VISIBILITY_CHANGED, |
373 |
|
|
self._OnMsgLayerVisibilityChanged) |
374 |
jonathan |
652 |
l.Subscribe(TITLE_CHANGED, self._OnMsgLayerTitleChanged) |
375 |
jonathan |
542 |
self.SetPyData(id, l) |
376 |
jonathan |
632 |
self.__SetVisibilityStyle(l.Visible(), id) |
377 |
jonathan |
542 |
|
378 |
|
|
self.layer2id[l] = id |
379 |
|
|
|
380 |
|
|
self.__FillTreeLayer(id) |
381 |
|
|
self.Expand(id) |
382 |
|
|
|
383 |
|
|
self.Thaw() |
384 |
|
|
|
385 |
|
|
def __FillTreeLayer(self, pid): |
386 |
|
|
layer = self.GetPyData(pid) |
387 |
|
|
|
388 |
|
|
self.Freeze() |
389 |
|
|
|
390 |
|
|
self.DeleteChildren(pid) |
391 |
|
|
|
392 |
|
|
clazz = layer.GetClassification() |
393 |
|
|
|
394 |
|
|
shapeType = layer.ShapeType() |
395 |
|
|
|
396 |
jonathan |
632 |
show = layer.Visible() |
397 |
jonathan |
542 |
for g in clazz: |
398 |
jonathan |
639 |
if g.IsVisible(): |
399 |
|
|
id = self.AppendItem(pid, g.GetDisplayText()) |
400 |
|
|
self.SetPyData(id, g) |
401 |
|
|
self.__SetVisibilityStyle(show, id) |
402 |
jonathan |
542 |
|
403 |
jonathan |
639 |
bmp = self.__BuildGroupImage(g, shapeType) |
404 |
jonathan |
542 |
|
405 |
jonathan |
639 |
if bmp is None: |
406 |
|
|
self.SetItemImage(id, self.emptyImageIndex) |
407 |
|
|
else: |
408 |
|
|
i = self.image_list.Add(bmp) |
409 |
|
|
self.SetItemImage(id, i) |
410 |
jonathan |
542 |
|
411 |
|
|
self.Thaw() |
412 |
|
|
|
413 |
|
|
def __BuildGroupImage(self, group, shapeType): |
414 |
jonathan |
605 |
assert isinstance(group, ClassGroup) |
415 |
jonathan |
542 |
|
416 |
|
|
bmp = wxEmptyBitmap(BMP_SIZE_W, BMP_SIZE_H) |
417 |
|
|
#brush = wxBrush(Color2wxColour(item[1]), wxSOLID) |
418 |
|
|
dc = wxMemoryDC() |
419 |
|
|
dc.SelectObject(bmp) |
420 |
|
|
dc.Clear() |
421 |
|
|
|
422 |
|
|
self.previewer.Draw(dc, None, group.GetProperties(), shapeType) |
423 |
|
|
|
424 |
|
|
return bmp |
425 |
|
|
|
426 |
|
|
def __DeleteAllItems(self): |
427 |
|
|
|
428 |
jonathan |
572 |
while len(self.layer2id) > 0: |
429 |
|
|
layer, id = self.layer2id.popitem() |
430 |
|
|
layer.Unsubscribe(LAYER_CHANGED, |
431 |
|
|
self._OnMsgLayerChanged) |
432 |
|
|
layer.Unsubscribe(LAYER_VISIBILITY_CHANGED, |
433 |
|
|
self._OnMsgLayerVisibilityChanged) |
434 |
jonathan |
652 |
layer.Unsubscribe(TITLE_CHANGED, self._OnMsgLayerTitleChanged) |
435 |
jonathan |
542 |
|
436 |
jonathan |
578 |
self.DeleteAllItems() |
437 |
|
|
|
438 |
jonathan |
632 |
def __SetVisibilityStyle(self, visible, id): |
439 |
jonathan |
572 |
font = self.GetItemFont(id) |
440 |
jonathan |
542 |
|
441 |
jonathan |
632 |
if visible: |
442 |
jonathan |
572 |
font.SetStyle(wxNORMAL) |
443 |
|
|
color = wxBLACK |
444 |
|
|
else: |
445 |
|
|
font.SetStyle(wxITALIC) |
446 |
|
|
color = wxLIGHT_GREY |
447 |
jonathan |
542 |
|
448 |
jonathan |
572 |
self.SetItemTextColour(id, color) |
449 |
|
|
self.SetItemFont(id, font) |
450 |
|
|
|
451 |
|
|
def __ShowHideLayer(self, layer): |
452 |
|
|
parent = self.layer2id[layer] |
453 |
jonathan |
605 |
assert parent.IsOk() |
454 |
jonathan |
542 |
|
455 |
jonathan |
632 |
visible = layer.Visible() |
456 |
jonathan |
542 |
|
457 |
jonathan |
632 |
self.__SetVisibilityStyle(visible, parent) |
458 |
jonathan |
542 |
|
459 |
jonathan |
572 |
id, cookie = self.GetFirstChild(parent, 123) |
460 |
jonathan |
542 |
|
461 |
jonathan |
572 |
while id.IsOk(): |
462 |
jonathan |
632 |
self.__SetVisibilityStyle(visible, id) |
463 |
jonathan |
572 |
id, cookie = self.GetNextChild(parent, cookie) |
464 |
|
|
|