Update of /cvsroot/freevo/freevo/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20732

Modified Files:
        window.py 
Log Message:
Documentation update and cleanup

Index: window.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/window.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** window.py   5 Oct 2004 19:50:54 -0000       1.1
--- window.py   9 Oct 2004 09:43:33 -0000       1.2
***************
*** 1,24 ****
  # -*- coding: iso-8859-1 -*-
! # -----------------------------------------------------------------------
! # Window - A window for freevo.
! # -----------------------------------------------------------------------
  # $Id$
  #
  #
! # -----------------------------------------------------------------------
! # $Log$
! # Revision 1.1  2004/10/05 19:50:54  dischi
! # Cleanup gui/widgets:
! # o remove unneeded widgets
! # o move window and boxes to the gui main level
! # o merge all popup boxes into one file
! # o rename popup boxes
! #
! #
! # -----------------------------------------------------------------------
! #
  # Freevo - A Home Theater PC framework
  #
! # Copyright (C) 2002 Krister Lagerstrom, et al.
  #
  # This program is free software; you can redistribute it and/or modify
--- 1,22 ----
  # -*- coding: iso-8859-1 -*-
! # -----------------------------------------------------------------------------
! # window.py - A window for popup boxes in freevo.
! # -----------------------------------------------------------------------------
  # $Id$
  #
+ # This file defines a window used by the different kinds of popup boxes in
+ # Freevo. A window is always on top and gets the focus. The class only
+ # handles the basic window functions like show/destroy and drawing the
+ # background and border of the window. What the window should do needs to be
+ # defined in inherting classes like WaitBox in popups.py.
  #
! # -----------------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
+ # Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
  #
! # First Version: Dirk Meyer <[EMAIL PROTECTED]>
! # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
! #
! # Please see the file freevo/Docs/CREDITS for a complete list of authors.
  #
  # This program is free software; you can redistribute it and/or modify
***************
*** 36,40 ****
  # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  #
! # ----------------------------------------------------------------------
  
  # python imports
--- 34,38 ----
  # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  #
! # -----------------------------------------------------------------------------
  
  # python imports
***************
*** 47,84 ****
  from displays import get_display
  from theme_engine import get_theme
! from widgets import Rectangle, CanvasContainer
  
  
! class Window(CanvasContainer):
      """
      """
!     def __init__(self, x=None, y=None, width=None, height=None):
!         CanvasContainer.__init__(self)
          self.set_zindex(100)
!         
!         self._display_width  = get_display().width
!         self._display_height = get_display().height
!         self.event_context   = 'input'
! 
!         self.center_on_screen = False
! 
!         if width == None:
!             width  = self._display_width / 2
! 
!         if height == None:
!             height = self._display_height / 4
  
!         if x == None:
!             x = self._display_width/2 - width/2
  
!         if y == None:
!             y  = self._display_height/2 - height/2
!             self.center_on_screen = True
  
          layout = get_theme().popup.content
-         
-         self.set_size((width, height))
-         self.set_pos((x, y))
-         
          self.widget_normal   = layout.types['widget']
          self.widget_selected = layout.types['selected']
--- 45,79 ----
  from displays import get_display
  from theme_engine import get_theme
! from widgets import Rectangle, Container
  
  
! class Window(Container):
      """
+     A window for Freevo popups. This class will only draw the background and
+     border and has some basic functions to get skin informations and show
+     hide methods. When a window is shown, it will get the focus to the
+     eventhandler that needs to be defined by inherting classes.
+     Not setting x, y, width and height will result in centering the window
+     with a default size.
      """
!     def __init__(self, pos=(None, None), size=(None, None)):
!         Container.__init__(self)
          self.set_zindex(100)
!         self.event_context = 'input'
!         self.__display  = None
  
!         # setting the size
!         width  = size[0] or get_display().width / 2
!         height = size[1] or get_display().height / 4
!         self.set_size((width, height))
  
!         # setting the position
!         x, y = pos
!         if x == None: x = get_display().width/2 - width/2
!         if y == None: y = get_display().height/2 - height/2
!         self.set_pos((x, y))
  
+         # get theme values how the window should look like
          layout = get_theme().popup.content
          self.widget_normal   = layout.types['widget']
          self.widget_selected = layout.types['selected']
***************
*** 86,120 ****
          self.button_selected = layout.types['button selected']
          self.content_spacing = layout.spacing
!         
          self.__c_x = int(eval(str(layout.x), { 'MAX': 0}))
          self.__c_y = int(eval(str(layout.y), { 'MAX': 0}))
          self.__c_w = -int(eval(str(layout.width), { 'MAX': 0}))
          self.__c_h = -int(eval(str(layout.height), { 'MAX': 0}))
-         self._display  = None
  
  
      def __create_background(self, screen):
          """
!         The draw function.
          """
!         _debug_('Window::__create_background %s' % self, 1)
!         
!         for o in get_theme().popup.background:
!             if o.type == 'rectangle':
!                 r = copy.deepcopy(o)
!                 r.width  = eval(str(r.width),  { 'MAX' : self.width })
!                 r.height = eval(str(r.height), { 'MAX' : self.height })
! 
!                 if not r.width:
!                     r.width  = self.width
!                 if not r.height:
!                     r.height = self.height
!                 if r.x + r.width > self.width:
!                     r.width = self.width - r.x
!                 if r.y + r.height > self.height:
!                     r.height = self.height - r.y
  
!             r = Rectangle((r.x, r.y), (r.width, r.height),
!                           r.bgcolor, r.size, r.color, r.radius)
              r.set_zindex(-1)
              self.add_child(r)
--- 81,111 ----
          self.button_selected = layout.types['button selected']
          self.content_spacing = layout.spacing
! 
!         # get position where the content should be inside the window
          self.__c_x = int(eval(str(layout.x), { 'MAX': 0}))
          self.__c_y = int(eval(str(layout.y), { 'MAX': 0}))
          self.__c_w = -int(eval(str(layout.width), { 'MAX': 0}))
          self.__c_h = -int(eval(str(layout.height), { 'MAX': 0}))
  
  
      def __create_background(self, screen):
          """
!         Draw the background and border of the window based on the theme
!         settings.
          """
!         objects = get_theme().popup.background
!         for r in filter(lambda x: x.type == 'rectangle', objects):
!             # calculate size of the rectangle
!             width  = eval(str(r.width),  { 'MAX' : self.width })
!             height = eval(str(r.height), { 'MAX' : self.height })
!             if not width: width = self.width
!             if not height: height = self.height
!             if r.x + width > self.width: width = self.width - r.x
!             if r.y + height > self.height: height = self.height - r.y
  
!             # draw the rectangle and add it to the window, use zindex = -1
!             # to make sure it is below the content
!             r = Rectangle((r.x, r.y), (width, height), r.bgcolor, r.size,
!                           r.color, r.radius)
              r.set_zindex(-1)
              self.add_child(r)
***************
*** 122,129 ****
--- 113,126 ----
  
      def get_content_pos(self):
+         """
+         Return the position of the content inside the window
+         """
          return self.__c_x, self.__c_y
  
  
      def get_content_size(self):
+         """
+         Return the size the content can have inside the window
+         """
          w, h = self.get_size()
          return w - self.__c_w, h - self.__c_h
***************
*** 131,148 ****
              
      def show(self):
!         if self._display:
              return
          eventhandler.add_window(self)
!         self._display = get_display()
!         self.__create_background(self._display)
!         self._display.add_child(self)
!         self._display.update()
  
  
      def destroy(self):
          eventhandler.remove_window(self)
!         if not self._display:
              return
!         self._display.remove_child(self)
!         self._display.update()
!         self._display = None
--- 128,158 ----
              
      def show(self):
!         """
!         Show the window on the screen
!         """
!         if self.__display:
              return
          eventhandler.add_window(self)
!         self.__display = get_display()
!         self.__create_background(self.__display)
!         self.__display.add_child(self)
!         self.__display.update()
  
  
      def destroy(self):
+         """
+         Destroy (close) the window
+         """
          eventhandler.remove_window(self)
!         if not self.__display:
              return
!         self.__display.remove_child(self)
!         self.__display.update()
!         self.__display = None
! 
! 
!     def eventhandler(self):
!         """
!         Eventhandler for the window, this raw window has nothing to do
!         """
!         return False



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to