mailr10643 - /branches/bieri_gui/gui_bieri/about.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on February 04, 2010 - 17:26:
Author: bugman
Date: Thu Feb  4 17:26:02 2010
New Revision: 10643

URL: http://svn.gna.org/viewcvs/relax?rev=10643&view=rev
Log:
Changed how the element layout is handled in the about relax widget.

The method offset() has been added.  When a value is sent it, the offset 
increments.  The method
always returns the current offset value.


Modified:
    branches/bieri_gui/gui_bieri/about.py

Modified: branches/bieri_gui/gui_bieri/about.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/about.py?rev=10643&r1=10642&r2=10643&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/about.py (original)
+++ branches/bieri_gui/gui_bieri/about.py Thu Feb  4 17:26:02 2010
@@ -161,6 +161,9 @@
     def build_widget(self):
         """Build the about dialog."""
 
+        # A global Y offset for packing the elements together (initialise to 
the boarder position).
+        self.offset(self.boarder)
+
         # The relax icon.
         self.draw_icon()
 
@@ -183,17 +186,17 @@
         # Set the font.
         font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.NORMAL)
         self.dc.SetFont(font)
-
-        # Offset.
-        offset = 270
 
         # The text extent.
         x1, y1 = self.dc.GetTextExtent(self.info.copyright[0])
         x2, y2 = self.dc.GetTextExtent(self.info.copyright[1])
 
-        # Draw the text.
-        self.dc.DrawText(self.info.copyright[0], self.boarder + (self.dim_x 
- x1)/2, offset)
-        self.dc.DrawText(self.info.copyright[1], self.boarder + (self.dim_x 
- x2)/2, offset+y1+3)
+        # Draw the text, with a starting spacer.
+        self.dc.DrawText(self.info.copyright[0], self.boarder + (self.dim_x 
- x1)/2, self.offset(25))
+        self.dc.DrawText(self.info.copyright[1], self.boarder + (self.dim_x 
- x2)/2, self.offset(y1+3))
+
+        # Add the text extent.
+        self.offset(y2)
 
 
     def draw_description(self):
@@ -206,15 +209,21 @@
         # The text extent.
         x, y = self.dc.GetTextExtent(self.info.desc)
 
-        # Draw the text.
-        self.dc.DrawText(self.info.desc, self.boarder + (self.dim_x - x)/2, 
230)
+        # Draw the text, with a spacer.
+        self.dc.DrawText(self.info.desc, self.boarder + (self.dim_x - x)/2, 
self.offset(20))
+
+        # Add the text extent.
+        self.offset(y)
 
 
     def draw_icon(self):
         """Draw the relax icon on the canvas."""
 
         # Add the relax logo.
-        
self.dc.DrawBitmap(wx.Bitmap(IMAGE_PATH+'ulysses_shadowless_400x168.png'), 
self.boarder, self.boarder, True)
+        
self.dc.DrawBitmap(wx.Bitmap(IMAGE_PATH+'ulysses_shadowless_400x168.png'), 
self.boarder, self.offset(), True)
+
+        # Add the bitmap width to the offset.
+        self.offset(168)
 
 
     def draw_licence(self):
@@ -223,9 +232,6 @@
         # Set the font.
         font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.NORMAL)
         self.dc.SetFont(font)
-
-        # Offset.
-        offset = 325
 
         # Wrap the text.
         lines = wrap(self.info.licence, 60)
@@ -237,13 +243,16 @@
             if y > max_y:
                 max_y = y
 
+        # Add a top spacer.
+        self.offset(10)
+
         # Draw.
         for line in lines:
             # Draw the text.
-            self.dc.DrawText(line, self.boarder, offset)
+            self.dc.DrawText(line, self.boarder, self.offset())
 
             # Update the offset.
-            offset = offset + max_y + 1
+            self.offset(max_y + 1)
 
 
     def draw_title(self):
@@ -259,5 +268,28 @@
         # The text extent.
         x, y = self.dc.GetTextExtent(text)
 
-        # Draw the text.
-        self.dc.DrawText(text, self.boarder + (self.dim_x - x)/2, 20+168)
+        # Draw the text, with a spacer.
+        self.dc.DrawText(text, self.boarder + (self.dim_x - x)/2, 
self.offset(20))
+
+        # Add the text extent.
+        self.offset(y)
+
+
+    def offset(self, val=0):
+        """Shift the offset by the given value and return the offset.
+
+        @keyword val:   The value to add to the offset (can be negative).
+        @type val:      int
+        @return:        The current offset.
+        @rtype:         int
+        """
+
+        # Initialisation.
+        if not hasattr(self, '_offset_val'):
+            self._offset_val = 0
+
+        # Shift.
+        self._offset_val = self._offset_val + val
+
+        # Return.
+        return self._offset_val




Related Messages


Powered by MHonArc, Updated Thu Feb 04 17:40:02 2010