/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/tree.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/tree.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/thuban/Thuban/UI/tree.py revision 882 by jonathan, Fri May 9 16:34:28 2003 UTC branches/WIP-pyshapelib-bramz/Thuban/UI/tree.py revision 2734 by bramz, Thu Mar 1 12:42:59 2007 UTC
# Line 1  Line 1 
 #! /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]>
# Line 11  __version__ = "$Revision$" Line 10  __version__ = "$Revision$"
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
# Line 22  from Thuban.Model.messages import CHANGE Line 21  from Thuban.Model.messages import CHANGE
21  from Thuban.Model.layer import Layer  from Thuban.Model.layer import Layer
22  from Thuban.Model.map import Map  from Thuban.Model.map import Map
23    
24  from dialogs import NonModalDialog  from dialogs import NonModalNonParentDialog
25  from messages import SESSION_REPLACED, LAYER_SELECTED  from messages import SESSION_REPLACED, LAYER_SELECTED
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    
# Line 52  class SessionTreeCtrl(wxTreeCtrl): Line 51  class SessionTreeCtrl(wxTreeCtrl):
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
# Line 73  class SessionTreeCtrl(wxTreeCtrl): Line 72  class SessionTreeCtrl(wxTreeCtrl):
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:
# Line 86  class SessionTreeCtrl(wxTreeCtrl): Line 85  class SessionTreeCtrl(wxTreeCtrl):
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    
# Line 145  class SessionTreeCtrl(wxTreeCtrl): Line 144  class SessionTreeCtrl(wxTreeCtrl):
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)
# Line 219  class SessionTreeCtrl(wxTreeCtrl): Line 218  class SessionTreeCtrl(wxTreeCtrl):
218              self.SelectItem(item)              self.SelectItem(item)
219    
220    
221  class SessionTreeView(NonModalDialog):  class SessionTreeView(NonModalNonParentDialog):
222    
223      """Non modal dialog showing the session as a tree"""      """Non modal dialog showing the session as a tree"""
224    
225      def __init__(self, parent, app, name):      def __init__(self, parent, app, name):
226          NonModalDialog.__init__(self, parent, name, _("Session"))          NonModalNonParentDialog.__init__(self, parent, name, _("Session"))
227          self.tree = SessionTreeCtrl(self, -1, parent, app)          self.tree = SessionTreeCtrl(self, -1, parent, app)
228    
229      def OnClose(self, event):      def OnClose(self, event):
230          NonModalDialog.OnClose(self, event)          NonModalNonParentDialog.OnClose(self, event)
231    
232          # if there were a way to get notified when the tree control          # if there were a way to get notified when the tree control
233          # itself is destroyed we could use that to unsubscribe instead          # itself is destroyed we could use that to unsubscribe instead

Legend:
Removed from v.882  
changed lines
  Added in v.2734

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26