[z3-checkins] r15219 - z3/zopejam/trunk/src/zopejam

hathawsh at codespeak.net hathawsh at codespeak.net
Thu Jul 28 09:17:19 CEST 2005


Author: hathawsh
Date: Thu Jul 28 09:17:17 2005
New Revision: 15219

Modified:
   z3/zopejam/trunk/src/zopejam/propbook.py
Log:
Rearranged the property editing header.  It looks a little like an 
email client now.


Modified: z3/zopejam/trunk/src/zopejam/propbook.py
==============================================================================
--- z3/zopejam/trunk/src/zopejam/propbook.py	(original)
+++ z3/zopejam/trunk/src/zopejam/propbook.py	Thu Jul 28 09:17:17 2005
@@ -56,25 +56,32 @@
         self.panel.DestroyChildren()
         if len(directives) == 1:
             self.directive = directives[0]
+
+            error = None
             t = self.directive.getType()
             if t is None:
-                self.addLabel(
-                    "Directive type '%s:%s' not found"
-                    % self.directive.element.name, error=True)
+                self.info = None
+                error = "Directive type '%s' not found" % (
+                    self.directive.getAbbreviatedTypeName())
+            else:
+                self.info = t.getSchemaInfo()
+                if self.info.error:
+                    error = "Error loading schema %s:\n%s" % (
+                        self.info.name, self.info.error)
+
+            self.addHeader()
+            if error:
+                self.addLabel(error, error=True)
             else:
                 self.win = scrolledpanel.ScrolledPanel(self.panel)
+                self.win.SetBackgroundColour(wx.WHITE)
                 self.win.SetSizer(wx.BoxSizer(wx.VERTICAL))
                 self.panel.GetSizer().Add(
                     self.win, proportion=1, flag=wx.EXPAND)
-                self.info = t.getSchemaInfo()
-                if self.info.error:
-                    self.addLabel(
-                        "Error loading schema %s:\n"
-                        "%s" % (self.info.name, self.info.error), error=True)
-                self.addHeader()
                 self.addFields()
-                self.panel.Layout()
                 self.win.SetupScrolling(scroll_x=False)
+            self.panel.Layout()
+
         elif not directives:
             self.directive = None
             self.addLabel("No directives are selected.")
@@ -92,43 +99,78 @@
         self.panel.GetSizer().Add(label, flag=wx.EXPAND|wx.ALL, border=4)
 
     def addHeader(self):
-        sizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.win.GetSizer().Add(sizer, flag=wx.ALL, border=4)
-
-        type_name = self.directive.getAbbreviatedTypeName()
-        def getTypePopup():
-            return 'about %s <a href="#">...</a>' % type_name
-        label = StaticTextWithPopup(self.win, -1, type_name, getTypePopup)
-        label.SetFont(self.gui.bold_font)
-        sizer.Add(label)
-
-        label = wx.StaticText(self.win, -1, ' in file ')
-        sizer.Add(label)
+        header = wx.Panel(self.panel)
+        self.panel.GetSizer().Add(header, flag=wx.ALL|wx.EXPAND, border=4)
+        header_sizer = wx.FlexGridSizer(rows=0, cols=2, vgap=2, hgap=12)
+        header.SetSizer(header_sizer)
+        header_sizer.AddGrowableCol(1, 1)
+
+        def labelRow(text):
+            if text:
+                text_ctrl = wx.StaticText(header, -1, text)
+                text_ctrl.SetFont(self.gui.bold_font)
+                header_sizer.Add(
+                    text_ctrl, flag=wx.ALIGN_RIGHT)
+            else:
+                # add a spacer
+                header_sizer.Add((0,0))
 
+        labelRow("Source File:")
         cfg = self.directive.element.config_file
         fn = cfg.getAbbreviatedFilename(trim_default=False)
         def getFilenamePopup():
             return 'about %s <a href="#">...</a>' % fn
-        label = StaticTextWithPopup(self.win, -1, fn, getFilenamePopup)
-        label.SetFont(self.gui.bold_font)
-        sizer.Add(label)
-
-        sizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.win.GetSizer().Add(
-            sizer, flag=wx.LEFT|wx.RIGHT|wx.BOTTOM, border=4)
-        lines = self.info.doc.lstrip().split('\n')
-        title_lines = []
-        for line in lines:
-            line = line.strip()
-            if not line:
+        label = StaticTextWithPopup(header, -1, fn, getFilenamePopup)
+        #label.SetFont(self.gui.bold_font)
+        header.GetSizer().Add(label)
+
+        chain = []
+        d = self.directive
+        while True:
+            chain.append(d)
+            if d.element is not None and d.element.parent is not None:
+                d = d.element.parent.directive
+            else:
                 break
-            title_lines.append(line)
-        title = ' '.join(title_lines)
-        def getSchemaPopup():
-            return 'about %s <a href="#">...</a>' % self.info.name
-        label = StaticTextWithPopup(self.win, -1, title, getSchemaPopup)
-        label.SetFont(self.gui.italic_font)
-        sizer.Add(label)
+        chain.reverse()
+
+        count = 0
+        for d in chain:
+            if d is self.directive:
+                labelRow("Directive:")
+            elif count == 0:
+                labelRow("Context:")
+            else:
+                labelRow("")
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            header.GetSizer().Add(sizer)
+            sizer.Add((count * 24, 0), 0)
+            type_name = d.getAbbreviatedTypeName()
+            def getTypePopup(d=d, type_name=type_name):
+                return 'about %s <a href="#">...</a>' % type_name
+            label = StaticTextWithPopup(header, -1, type_name, getTypePopup)
+            if d is self.directive:
+                label.SetFont(self.gui.bold_font)
+            sizer.Add(label)
+            count += 1
+
+        if self.info is not None:
+            labelRow("Description:")
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            header.GetSizer().Add(sizer)
+            lines = self.info.doc.lstrip().split('\n')
+            title_lines = []
+            for line in lines:
+                line = line.strip()
+                if not line:
+                    break
+                title_lines.append(line)
+            title = ' '.join(title_lines)
+            def getSchemaPopup():
+                return 'about %s <a href="#">...</a>' % self.info.name
+            label = StaticTextWithPopup(header, -1, title, getSchemaPopup)
+            label.SetFont(self.gui.italic_font)
+            sizer.Add(label)
 
     def addFields(self):
         sizer = wx.FlexGridSizer(rows=0, cols=3, vgap=4, hgap=8)
@@ -397,8 +439,9 @@
 class StaticTextWithPopup(wx.Panel):
 
     def __init__(self, parent, id, text, get_popup_text,
-                 normal_color=wx.BLACK, hover_color=wx.BLUE):
+                 normal_color=wx.BLUE, hover_color=wx.RED):
         wx.Panel.__init__(self, parent, id)
+        self.SetBackgroundColour(parent.GetBackgroundColour())
         self.hovering = False
         self.normal_color = normal_color
         self.hover_color = hover_color


More information about the z3-checkins mailing list