mailr12002 - /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 December 28, 2010 - 21:03:
Author: bugman
Date: Tue Dec 28 21:03:30 2010
New Revision: 12002

URL: http://svn.gna.org/viewcvs/relax?rev=12002&view=rev
Log:
The draw_url() about window method now can place the URL at any position.

The centre flag can be used to centre the URL in the window, and the pos_x 
can place the text
anywhere.


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=12002&r1=12001&r2=12002&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/about.py (original)
+++ branches/bieri_gui/gui_bieri/about.py Tue Dec 28 21:03:30 2010
@@ -192,7 +192,7 @@
             self.cursor_type = 'normal'
 
 
-    def draw_url(self, url_text=None, point_size=11, 
family=wx.FONTFAMILY_ROMAN, carriage_ret=False):
+    def draw_url(self, url_text=None, point_size=11, 
family=wx.FONTFAMILY_ROMAN, pos_x=0, carriage_ret=False, centre=False):
         """Draw a URL as a hyperlink.
 
         @keyword url_text:      The text of the url.
@@ -201,6 +201,12 @@
         @type point_size:       int
         @keyword family:        The font family.
         @type family:           int
+        @keyword pos_x:         The starting x position for the text.
+        @type pos_x:            int
+        @keyword carriage_ret:  A flag which if True will cause a carriage 
return, by shifting the offset by y.
+        @type carriage_ret:     bool
+        @keyword centre:        A flag which if True will cause the URL to 
be centred in the window.
+        @type centre:           bool
         """
 
         # Set the font.
@@ -211,8 +217,12 @@
         # The text extent.
         x, y = self.dc.GetTextExtent(url_text)
 
-        # Draw the text, with a spacer.
-        text = self.dc.DrawText(url_text, self.border + (self.dim_x - x)/2, 
self.offset())
+        # Draw the text centred.
+        if centre:
+            pos_x = self.border + (self.dim_x - x)/2
+
+        # Draw the text.
+        text = self.dc.DrawText(url_text, pos_x, self.offset())
 
         # Store the position of the text.
         self.url_pos.append(zeros((2, 2), int))
@@ -279,19 +289,19 @@
             text_elements, url = self.split_refs(line)
 
             # Draw the text.
-            x_pos = self.border
+            pos_x = self.border
             for i in range(len(text_elements)):
                 # URL text.
                 if url[i]:
-                    self.draw_url(url_text=text_elements[i])
+                    self.draw_url(url_text=text_elements[i], pos_x=pos_x)
 
                 # Add the text.
                 else:
-                    self.dc.DrawText(text_elements[i], x_pos, self.offset())
+                    self.dc.DrawText(text_elements[i], pos_x, self.offset())
 
                 # The new x position.
                 x, y = self.dc.GetTextExtent(text_elements[i])
-                x_pos += x
+                pos_x += x
 
             # Update the offset.
             self.offset(max_y + 1)
@@ -490,7 +500,7 @@
         self.draw_description()
         self.draw_copyright()
         self.offset(10)
-        self.draw_url(url_text=self.info.website, carriage_ret=True)
+        self.draw_url(url_text=self.info.website, carriage_ret=True, 
centre=True)
         self.draw_icon()
         self.draw_desc_long()
         self.draw_licence()




Related Messages


Powered by MHonArc, Updated Tue Dec 28 21:20:02 2010