Author: bugman Date: Tue Dec 28 10:21:24 2010 New Revision: 11982 URL: http://svn.gna.org/viewcvs/relax?rev=11982&view=rev Log: The setting of the about window virtual size has been shifted to the virtual_size() method. 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=11982&r1=11981&r2=11982&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/about.py (original) +++ branches/bieri_gui/gui_bieri/about.py Tue Dec 28 10:21:24 2010 @@ -63,6 +63,9 @@ # Create a scrolled window. self.window = wx.ScrolledWindow(self, -1) + # Determine the virtual size of the window. + self.virtual_size() + # Initialise the y-offset variable. self._offset_val = 0 @@ -89,6 +92,134 @@ def create_buffered_dc(self): """Build the buffered dc containing the window contents.""" + + # The buffer for buffered drawing. + self.buffer = wx.EmptyBitmap(self.virt_x, self.virt_y) + + # Create the device context. + self.dc = wx.BufferedDC(None, self.buffer) + + # Set a background. + self.set_background() + + # Build the rest of the about widget. + self.build_widget() + + # Finish. + self.dc.EndDrawing() + + + def cursor_style(self, event): + """Dummy method for not changing the mouse cursor!""" + + # Terminate the event. + event.Skip() + + + def draw_title(self, text, point_size=14, family=wx.FONTFAMILY_ROMAN): + """Draw the title.""" + + # Set the font. + font = wx.Font(point_size, family, wx.NORMAL, wx.NORMAL) + self.dc.SetFont(font) + + # The text extent. + x, y = self.dc.GetTextExtent(text) + + # Draw the text, with a spacer. + self.dc.DrawText(text, self.border + (self.dim_x - x)/2, self.offset(15)) + + # Add the text extent. + self.offset(y) + + + def draw_wrapped_text(self, text, text_size=10, width=69, spacer=10): + """Generic method for drawing wrapped text in the relax about widget. + + @param text: The text to wrap and draw. + @type text: str + @keyword spacer: The pixel width of the spacer to place above the text block. + @type spacer: int + """ + + # Set the font. + font = wx.Font(text_size, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.NORMAL) + self.dc.SetFont(font) + + # Wrap the text. + lines = wrap(text, width) + + # Find the max y extent. + max_y = 0 + for line in lines: + x, y = self.dc.GetTextExtent(text) + 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.border, self.offset()) + + # Update the offset. + self.offset(max_y + 1) + + + def generate(self, event): + """Build the device context, add the background, and build the dialog. + + @param event: The wx event. + @type event: wx event + """ + + # Create the device context. + wx.BufferedPaintDC(self.window, self.buffer, wx.BUFFER_VIRTUAL_AREA) + + + def offset(self, val=0): + """Shift the y-offset by the given value and return the new offset. + + @keyword val: The value to add to the offset (can be negative). + @type val: int + @return: The new offset. + @rtype: int + """ + + # Shift. + self._offset_val = self._offset_val + val + + # Return. + return self._offset_val + + + def process_click(self, event): + """Base method which just closes the widget on a click event. + + @param event: The wx event. + @type event: wx event + """ + + # Close the widget. + self.Destroy() + + + def set_background(self): + """Build a background for the dialog.""" + + # Set a single colour. + if self.colour1 and not self.colour2: + self.SetBackgroundColour(self.colour1) + + # A gradient. + elif self.colour1 and self.colour2: + self.dc.GradientFillLinear((0, 0, self.virt_x, self.virt_y), self.colour1, self.colour2, wx.SOUTH) + + + def virtual_size(self): + """Determine the virtual size of the window.""" # Dimensions of the drawing area. if self.max_x: @@ -101,135 +232,14 @@ y = self.dim_y # Borders. - x = x + 2*self.border - y = y + 2*self.border + self.virt_x = x + 2*self.border + self.virt_y = y + 2*self.border # Set the window virtual size. - self.window.SetVirtualSize((x, y)) - - # The buffer for buffered drawing. - self.buffer = wx.EmptyBitmap(x, y) - - # Create the device context. - self.dc = wx.BufferedDC(None, self.buffer) - - # Set a background. - self.set_background() - - # Build the rest of the about widget. - self.build_widget() - - # Finish. - self.dc.EndDrawing() - - - def cursor_style(self, event): - """Dummy method for not changing the mouse cursor!""" - - # Terminate the event. - event.Skip() - - - def draw_title(self, text, point_size=14, family=wx.FONTFAMILY_ROMAN): - """Draw the title.""" - - # Set the font. - font = wx.Font(point_size, family, wx.NORMAL, wx.NORMAL) - self.dc.SetFont(font) - - # The text extent. - x, y = self.dc.GetTextExtent(text) - - # Draw the text, with a spacer. - self.dc.DrawText(text, self.border + (self.dim_x - x)/2, self.offset(15)) - - # Add the text extent. - self.offset(y) - - - def draw_wrapped_text(self, text, text_size=10, width=69, spacer=10): - """Generic method for drawing wrapped text in the relax about widget. - - @param text: The text to wrap and draw. - @type text: str - @keyword spacer: The pixel width of the spacer to place above the text block. - @type spacer: int - """ - - # Set the font. - font = wx.Font(text_size, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.NORMAL) - self.dc.SetFont(font) - - # Wrap the text. - lines = wrap(text, width) - - # Find the max y extent. - max_y = 0 - for line in lines: - x, y = self.dc.GetTextExtent(text) - 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.border, self.offset()) - - # Update the offset. - self.offset(max_y + 1) - - - def generate(self, event): - """Build the device context, add the background, and build the dialog. - - @param event: The wx event. - @type event: wx event - """ - - # Create the device context. - wx.BufferedPaintDC(self.window, self.buffer, wx.BUFFER_VIRTUAL_AREA) - - - def offset(self, val=0): - """Shift the y-offset by the given value and return the new offset. - - @keyword val: The value to add to the offset (can be negative). - @type val: int - @return: The new offset. - @rtype: int - """ - - # Shift. - self._offset_val = self._offset_val + val - - # Return. - return self._offset_val - - - def process_click(self, event): - """Base method which just closes the widget on a click event. - - @param event: The wx event. - @type event: wx event - """ - - # Close the widget. - self.Destroy() - - - def set_background(self): - """Build a background for the dialog.""" - - # Set a single colour. - if self.colour1 and not self.colour2: - self.SetBackgroundColour(self.colour1) - - # A gradient. - elif self.colour1 and self.colour2: - self.dc.GradientFillLinear((0, 0, self.total_x, self.total_y), self.colour1, self.colour2, wx.SOUTH) + self.window.SetVirtualSize((self.virt_x, self.virt_y)) + + # Add y scrolling, if needed. + self.window.SetScrollRate(0,20)