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

Modified Files:
        tvlisting_area.py 
Log Message:
cleanup, adjust to new area.py

Index: tvlisting_area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/areas/tvlisting_area.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** tvlisting_area.py   28 Dec 2004 19:50:58 -0000      1.24
--- tvlisting_area.py   30 Dec 2004 11:28:56 -0000      1.25
***************
*** 91,107 ****
          self.objects    = []
          self.background = None
!         
  
      def __calc_items_geometry(self):
!         # get the content skin information
!         content   = self.calc_geometry(self.layout.content, copy_object=True)
  
          # get all values for the different types
!         label_val     = content.types['label']
!         head_val      = content.types['head']
!         selected_val  = content.types['selected']
!         default_val   = content.types['default']
!         scheduled_val = content.types['scheduled']
!         conflict_val  = content.types['conflict']
  
          self.all_vals = label_val, head_val, selected_val, default_val, \
--- 91,107 ----
          self.objects    = []
          self.background = None
! 
  
      def __calc_items_geometry(self):
!         # get the settings
!         settings = self.settings
  
          # get all values for the different types
!         label_val     = settings.types['label']
!         head_val      = settings.types['head']
!         selected_val  = settings.types['selected']
!         default_val   = settings.types['default']
!         scheduled_val = settings.types['scheduled']
!         conflict_val  = settings.types['conflict']
  
          self.all_vals = label_val, head_val, selected_val, default_val, \
***************
*** 116,124 ****
          label_width = label_val.width
          if label_val.rectangle:
!             r = self.calc_rectangle(label_val.rectangle, label_width,
!                                     label_val.font.height)[2]
              label_width = r.width
          else:
!             label_width += content.spacing
  
  
--- 116,124 ----
          label_width = label_val.width
          if label_val.rectangle:
!             r = label_val.rectangle.calculate(label_width,
!                                               label_val.font.height)[2]
              label_width = r.width
          else:
!             label_width += settings.spacing
  
  
***************
*** 126,135 ****
          head_h = head_val.font.height
          if head_val.rectangle:
!             r = self.calc_rectangle(head_val.rectangle, 20,
!                                     head_val.font.height)[2]
!             head_h = max(head_h, r.height + content.spacing)
!             content_y = content.y + r.height + content.spacing
          else:
!             content_y = content.y + head_val.font.height + content.spacing
  
  
--- 126,134 ----
          head_h = head_val.font.height
          if head_val.rectangle:
!             r = head_val.rectangle.calculate(20, head_val.font.height)[2]
!             head_h = max(head_h, r.height + settings.spacing)
!             settings_y = settings.y + r.height + settings.spacing
          else:
!             settings_y = settings.y + head_val.font.height + settings.spacing
  
  
***************
*** 138,150 ****
          for val in (label_val, default_val, selected_val, conflict_val):
              if val.rectangle:
!                 r = self.calc_rectangle(val.rectangle, 20, val.font.height)[2]
!                 item_h = max(item_h, r.height + content.spacing)
  
!         num_rows = (content.height + content.y - content_y) / item_h
!         return font_h, label_width, content_y, num_rows, item_h, head_h
  
  
  
!     def fit_item_in_rectangle(self, rectangle, width, height, font_h):
          """
          calculates the rectangle geometry and fits it into the area
--- 137,149 ----
          for val in (label_val, default_val, selected_val, conflict_val):
              if val.rectangle:
!                 r = val.rectangle.calculate(20, val.font.height)[2]
!                 item_h = max(item_h, r.height + settings.spacing)
  
!         num_rows = (settings.height + settings.y - settings_y) / item_h
!         return font_h, label_width, settings_y, num_rows, item_h, head_h
  
  
  
!     def __fit_in_rect(self, rectangle, width, height, font_h):
          """
          calculates the rectangle geometry and fits it into the area
***************
*** 152,156 ****
          x = 0
          y = 0
!         r = self.calc_rectangle(rectangle, width, font_h)[2]
          if r.width > width:
              r.width, width = width, width - (r.width - width)
--- 151,155 ----
          x = 0
          y = 0
!         r = rectangle.calculate(width, font_h)[2]
          if r.width > width:
              r.width, width = width, width - (r.width - width)
***************
*** 180,184 ****
  
  
!     def __draw_time_line(self, start_time, content, col_time, x0, y0,
                           n_cols, col_size, height):
          if self.last_start_time == start_time and self.time_obj:
--- 179,183 ----
  
  
!     def __draw_time_line(self, start_time, settings, col_time, x0, y0,
                           n_cols, col_size, height):
          if self.last_start_time == start_time and self.time_obj:
***************
*** 194,200 ****
          geo = _Geometry( 0, 0, col_size, height )
          if head_val.rectangle:
!             geo, rect = self.fit_item_in_rectangle( head_val.rectangle,
!                                                     col_size, height, height )
!             
          for i in range( n_cols ):
              if head_val.rectangle:
--- 193,199 ----
          geo = _Geometry( 0, 0, col_size, height )
          if head_val.rectangle:
!             geo, rect = self.__fit_in_rect( head_val.rectangle,
!                                             col_size, height, height )
! 
          for i in range( n_cols ):
              if head_val.rectangle:
***************
*** 206,210 ****
                                     time.localtime(start_time + col_time*i*60 
))
              self.time_obj.append(self.drawstring( t_str ,
!                                                  head_val.font, content,
                                                   x=( x0 + geo.x ),
                                                   y=( y0 + geo.y ),
--- 205,209 ----
                                     time.localtime(start_time + col_time*i*60 
))
              self.time_obj.append(self.drawstring( t_str ,
!                                                  head_val.font, settings,
                                                   x=( x0 + geo.x ),
                                                   y=( y0 + geo.y ),
***************
*** 215,221 ****
  
  
-         
  
!     def __draw_channel_list(self, channel_list, content, y0, width, item_h,
                              font_h):
          for o in self.chan_obj:
--- 214,220 ----
  
  
  
! 
!     def __draw_channel_list(self, channel_list, settings, y0, width, item_h,
                              font_h):
          for o in self.chan_obj:
***************
*** 223,237 ****
                  o.unparent()
          self.chan_obj = []
!                 
          label_val = self.all_vals[0]
          for channel in channel_list:
              ty0 = y0
!             tx0 = content.x
  
              logo_geo = [ tx0, ty0, width, font_h ]
  
              if label_val.rectangle:
!                 r = self.calc_rectangle(label_val.rectangle, width,
!                                         item_h)[2]
                  if r.x < 0:
                      tx0 -= r.x
--- 222,235 ----
                  o.unparent()
          self.chan_obj = []
! 
          label_val = self.all_vals[0]
          for channel in channel_list:
              ty0 = y0
!             tx0 = settings.x
  
              logo_geo = [ tx0, ty0, width, font_h ]
  
              if label_val.rectangle:
!                 r = label_val.rectangle.calculate(width, item_h)[2]
                  if r.x < 0:
                      tx0 -= r.x
***************
*** 252,259 ****
                  i = self.drawimage(img, (logo_geo[0], logo_geo[1]))
                  self.chan_obj.append(i)
!             else:  
                  self.chan_obj.append(self.drawstring(channel.name,
                                                       label_val.font,
!                                                      content, x=tx0, y=ty0,
                                                       width=r.width+2*r.x,
                                                       height=item_h))
--- 250,257 ----
                  i = self.drawimage(img, (logo_geo[0], logo_geo[1]))
                  self.chan_obj.append(i)
!             else:
                  self.chan_obj.append(self.drawstring(channel.name,
                                                       label_val.font,
!                                                      settings, x=tx0, y=ty0,
                                                       width=r.width+2*r.x,
                                                       height=item_h))
***************
*** 264,268 ****
  
  
-     
      def update(self):
          """
--- 262,265 ----
***************
*** 270,281 ****
          """
          menu      = self.menu
!         layout    = self.layout
!         area      = self.area_values
!         content   = self.calc_geometry(layout.content, copy_object=True)
! 
!         # to_listing     = menu.table
!         # n_cols   = len(to_listing[0])-1
  
!         n_cols = 4
          col_time = 30
  
--- 267,274 ----
          """
          menu      = self.menu
!         settings  = self.settings
  
!         # FIXME: move to skin
!         n_cols   = 4
          col_time = 30
  
***************
*** 325,335 ****
          #                        rightarrow.get_height())
  
- 
-         x_contents = content.x + content.spacing
-         y_contents = content.y + content.spacing
- 
-         w_contents = content.width  - 2 * content.spacing
-         h_contents = content.height - 2 * content.spacing
- 
          # Print the Date of the current list page
          dateformat = config.TV_DATEFORMAT
--- 318,321 ----
***************
*** 337,373 ****
              dateformat = '%e-%b'
  
!         r = _Geometry( 0, 0, label_width, font_h )
          if label_val.rectangle:
!             r = self.calc_rectangle( label_val.rectangle, label_width,
!                                      head_h )[ 2 ]
!             pad_x = 0
!             pad_y = 0
!             if r.x < 0: pad_x = -1 * r.x
!             if r.y < 0: pad_y = -1 * r.y
  
!         x_contents += r.width
!         y_contents += r.height
!         w_contents -= r.width
!         h_contents -= r.width
  
          # 1 sec = x pixels
!         prop_1sec = float(w_contents) / float(n_cols * col_time * 60)
          col_size = prop_1sec * 1800 # 30 minutes
  
- 
          if not self.background:
!             self.background = self.drawbox( x_contents - r.width,
!                                             y_contents - r.height,
!                                             r.width+1, head_h+1, r )
! 
! 
!         # use label padding for x; head padding for y
!         #  self.drawstring( time.strftime( dateformat,
!         #       time.localtime( to_listing[ 0 ][ 1 ] ) ),
!         # head_val.font, content,
!         # x=( x_contents  - r.width + pad_x ),
!         # y=( y_contents - r.height + ig.y ),
!         # width=( r.width - 2 * pad_x ), height=-1,
!         # align_v='center', align_h=head_val.align )
  
          start_time = self.last_start_time
--- 323,342 ----
              dateformat = '%e-%b'
  
!         r = _Geometry(0, 0, label_width, font_h)
          if label_val.rectangle:
!             r = label_val.rectangle.calculate( label_width, head_h )[ 2 ]
  
!         chan_x = settings.x + settings.spacing + r.width
!         chan_w = settings.width - 2 * settings.spacing - r.width
! 
!         timer_y = settings.y + settings.spacing
  
          # 1 sec = x pixels
!         prop_1sec = float(chan_w) / float(n_cols * col_time * 60)
          col_size = prop_1sec * 1800 # 30 minutes
  
          if not self.background:
!             self.background = self.drawbox(chan_x - r.width, timer_y,
!                                            r.width+1, head_h+1, r)
  
          start_time = self.last_start_time
***************
*** 387,392 ****
  
          # Print the time at the table's top
!         self.__draw_time_line(start_time, content, col_time, x_contents,
!                               y_contents - r.height, n_cols, col_size, head_h)
  
          self.last_start_time = start_time
--- 356,361 ----
  
          # Print the time at the table's top
!         self.__draw_time_line(start_time, settings, col_time, chan_x,
!                               timer_y, n_cols, col_size, head_h)
  
          self.last_start_time = start_time
***************
*** 400,407 ****
          # draw the channel list
          if self.last_channels != channel_list:
!             self.__draw_channel_list(channel_list, content, y0, label_width,
                                       item_h, font_h)
          self.last_channels = channel_list
!         
          for channel in channel_list:
              try:
--- 369,376 ----
          # draw the channel list
          if self.last_channels != channel_list:
!             self.__draw_channel_list(channel_list, settings, y0, label_width,
                                       item_h, font_h)
          self.last_channels = channel_list
! 
          for channel in channel_list:
              try:
***************
*** 412,430 ****
                      if prg.start < start_time:
                          flag_left = 1
!                         x0 = x_contents
                          t_start = start_time
                      else:
!                         x0 = x_contents + int(float(prg.start-start_time) * \
!                                               prop_1sec)
                          t_start = prg.start
  
                      if prg.stop > stop_time:
                          flag_right = 1
!                         w = w_contents + x_contents - x0
!                         x1 = x_contents + w_contents
                      else:
!                         w =  int( float(prg.stop - t_start) * prop_1sec )
!                         x1 = x_contents + int(float(prg.stop-start_time) * \
!                                               prop_1sec)
  
                      if prg == selected_prog:
--- 381,398 ----
                      if prg.start < start_time:
                          flag_left = 1
!                         x0 = chan_x
                          t_start = start_time
                      else:
!                         x0 = chan_x+int(float(prg.start-start_time)*prop_1sec)
                          t_start = prg.start
  
                      if prg.stop > stop_time:
                          flag_right = 1
!                         x1 = chan_x + chan_w
                      else:
!                         x1 = chan_x + 
int(float(prg.stop-start_time)*prop_1sec)
! 
!                     if x0 > x1:
!                         continue
  
                      if prg == selected_prog:
***************
*** 440,501 ****
                              val = default_val
  
-                     font = val.font
- 
-                     if x0 > x1:
-                         continue
- 
-                     # text positions
-                     tx0 = x0
-                     tx1 = x1
-                     ty0 = y0
- 
                      # calc the geometry values
!                     ig = _Geometry(0, 0, tx1-tx0+1, item_h)
                      if val.rectangle:
!                         ig, r = self.fit_item_in_rectangle(val.rectangle,
!                                                            tx1-tx0+1,
!                                                            item_h, font_h)
!                         self.objects.append(self.drawbox(tx0+r.x, ty0+r.y,
!                                                          r.width, item_h, r))
  
                      # draw left flag and reduce width and add to x0
                      if flag_left:
!                         tx0      += leftarrow_size[0]
                          ig.width -= leftarrow_size[0]
!                         if tx0 < tx1:
!                             di_y = ty0 + (item_h-leftarrow_size[1])/2
!                             d_i = self.drawimage(leftarrow,
!                                                  (tx0-leftarrow_size[0],
!                                                   di_y))
  
-                             self.objects.append(d_i)
                      # draw right flag and reduce width and x1
                      if flag_right:
!                         tx1      -= rightarrow_size[0]
                          ig.width -= rightarrow_size[0]
!                         if tx0 < tx1:
!                             di_y = ty0 + (item_h-rightarrow_size[1])/2
!                             self.objects.append(self.drawimage(rightarrow,
!                                                                (tx1, di_y)))
  
                      # draw the text
!                     if tx0 < tx1:
!                         self.objects.append(self.drawstring(prg.title, font,
!                                                             content,
!                                                             x=tx0+ig.x,
!                                                             y=ty0+ig.y,
!                                                             width=ig.width,
!                                                             height=ig.height,
!                                                             align_v='center',
!                                                             
align_h=val.align))
!             except Exception, e:
!                 log.error(e)
              y0 += item_h - 1
  
!         if start_channel > 0 and area.images['uparrow']:
              # up arrow needed
              if not self.up_arrow:
!                 self.up_arrow = 
self.drawimage(area.images['uparrow'].filename,
!                                                area.images['uparrow'])
          elif self.up_arrow:
              # no arrow needed but on the screen, remove it
--- 408,458 ----
                              val = default_val
  
                      # calc the geometry values
!                     ig = _Geometry(0, 0, x1-x0+1, item_h)
                      if val.rectangle:
!                         ig, r = self.__fit_in_rect(val.rectangle, x1-x0+1,
!                                                    item_h, font_h)
!                         box = self.drawbox(x0+r.x, y0+r.y, r.width, item_h, r)
!                         self.objects.append(box)
  
                      # draw left flag and reduce width and add to x0
                      if flag_left:
!                         x0 += leftarrow_size[0]
                          ig.width -= leftarrow_size[0]
!                         if x0 < x1:
!                             y = y0 + (item_h-leftarrow_size[1])/2
!                             x = x0 - leftarrow_size[0]
!                             image = self.drawimage(leftarrow, (x, y))
!                             if image:
!                                 self.objects.append(d_i)
  
                      # draw right flag and reduce width and x1
                      if flag_right:
!                         x1 -= rightarrow_size[0]
                          ig.width -= rightarrow_size[0]
!                         if x0 < x1:
!                             y = y0 + (item_h-rightarrow_size[1])/2
!                             image = self.drawimage(rightarrow, (x1, y))
!                             if image:
!                                 self.objects.append(image)
  
                      # draw the text
!                     if x0 < x1:
!                         txt = self.drawstring(prg.title, val.font, settings,
!                                               x0+ig.x, y0+ig.y, ig.width,
!                                               ig.height, 'center', val.align)
!                         if txt:
!                             self.objects.append(txt)
!             except:
!                 log.exception('tv_listing')
              y0 += item_h - 1
  
! 
!         if start_channel > 0 and settings.images['uparrow']:
              # up arrow needed
              if not self.up_arrow:
!                 ifile = settings.images['uparrow'].filename
!                 self.up_arrow = self.drawimage(ifile,
!                                                settings.images['uparrow'])
          elif self.up_arrow:
              # no arrow needed but on the screen, remove it
***************
*** 504,516 ****
  
          if len(pyepg.channels) >= start_channel+num_rows and \
!                area.images['downarrow']:
              if not self.down_arrow:
                  # down arrow needed
!                 if isinstance(area.images['downarrow'].y, str):
!                     v = copy.copy(area.images['downarrow'])
                      v.y = eval(v.y, {'MAX' : y0})
                  else:
!                     v = area.images['downarrow']
!                 fname = area.images['downarrow'].filename
                  self.down_arrow = self.drawimage(fname, v)
          elif self.down_arrow:
--- 461,473 ----
  
          if len(pyepg.channels) >= start_channel+num_rows and \
!                settings.images['downarrow']:
              if not self.down_arrow:
                  # down arrow needed
!                 if isinstance(settings.images['downarrow'].y, str):
!                     v = copy.copy(settings.images['downarrow'])
                      v.y = eval(v.y, {'MAX' : y0})
                  else:
!                     v = settings.images['downarrow']
!                 fname = settings.images['downarrow'].filename
                  self.down_arrow = self.drawimage(fname, v)
          elif self.down_arrow:
***************
*** 518,520 ****
              self.down_arrow.unparent()
              self.down_arrow = None
-             
--- 475,476 ----



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to