Update of /cvsroot/freevo/freevo/src/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv13791
Modified Files:
LetterBox.py LetterBoxGroup.py __init__.py
Added Files:
PasswordInputBox.py PasswordLetterBox.py
Log Message:
New classes: PasswordInputBox, PasswordLetterBox.
PasswordLetterBox is a subclass of Letterbox, PasswordInputBox does not
extend InputBox but instead is also a subclass of PopupBox. LetterBoxGroup
has a new constructor argument called 'type' which when set to 'password'
will make a LetterBoxGroup of PasswordLetterBox's rather than Letterbox's.
--- NEW FILE: PasswordInputBox.py ---
#if 0 /*
# ------------------------------------------------------------------------
# PasswordInputBox.py - a popup box that has a message and allows the user
# to input a password using the remote control
# ------------------------------------------------------------------------
# $Id: PasswordInputBox.py,v 1.1 2003/03/30 17:21:20 rshortt Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: PasswordInputBox.py,v $
# Revision 1.1 2003/03/30 17:21:20 rshortt
# New classes: PasswordInputBox, PasswordLetterBox.
# PasswordLetterBox is a subclass of Letterbox, PasswordInputBox does not
# extend InputBox but instead is also a subclass of PopupBox. LetterBoxGroup
# has a new constructor argument called 'type' which when set to 'password'
# will make a LetterBoxGroup of PasswordLetterBox's rather than Letterbox's.
#
#
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
# 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
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ----------------------------------------------------------------------- */
#endif
import config
from GUIObject import *
from PopupBox import *
from Color import *
from Button import *
from Border import *
from Label import *
from LetterBoxGroup import *
from types import *
DEBUG = 0
class PasswordInputBox(PopupBox):
"""
left x coordinate. Integer
top y coordinate. Integer
width Integer
height Integer
text String to print.
handler Function to call after pressing ENTER.
bg_color Background color (Color)
fg_color Foreground color (Color)
icon icon
border Border
bd_color Border color (Color)
bd_width Border width Integer
"""
def __init__(self, parent=None, text=" ", handler=None, left=None, top=None,
width=300, height=160, bg_color=None, fg_color=None, icon=None,
border=None, bd_color=None, bd_width=None):
self.handler = handler
PopupBox.__init__(self, parent, text, left, top, width, height,
bg_color, fg_color, icon, border, bd_color, bd_width)
self.set_v_align(Align.NONE)
self.set_h_align(Align.CENTER)
self.label.top = self.top + 25
self.lbg = LetterBoxGroup(type='password')
bleft = self.left + self.width/2 - self.lbg.width/2
btop = self.top + self.height - self.lbg.height - 25
self.lbg.set_position(bleft, btop)
self.add_child(self.lbg)
def eventhandler(self, event):
if event == self.rc.LEFT or event == self.rc.UP:
self.lbg.change_selected_box('left')
self.lbg.draw()
self.osd.update(self.lbg.get_rect())
return
elif event == self.rc.RIGHT or event == self.rc.DOWN:
self.lbg.change_selected_box('right')
self.lbg.draw()
self.osd.update(self.lbg.get_rect())
return
elif event == self.rc.ENTER or event == self.rc.SELECT:
self.destroy()
if self.handler: self.handler(self.lbg.get_word())
return
elif event == self.rc.EXIT:
self.destroy()
return
elif [self.rc.K1, self.rc.K2, self.rc.K3, self.rc.K4, self.rc.K5,
self.rc.K6, self.rc.K7, self.rc.K8, self.rc.K9,
self.rc.K0].count(event) > 0:
the_box = self.lbg.get_selected_box()
the_box.cycle_phone_char(event)
if self.lbg.boxes.index(the_box) != len(self.lbg.boxes)-1:
self.lbg.change_selected_box('right')
self.lbg.draw()
self.osd.update(self.lbg.get_rect())
return
else:
return self.parent.eventhandler(event)
--- NEW FILE: PasswordLetterBox.py ---
#if 0 /*
# -----------------------------------------------------------------------
# PasswordLetterBox.py - a gui widget for inputting a password character
# -----------------------------------------------------------------------
# $Id: PasswordLetterBox.py,v 1.1 2003/03/30 17:21:20 rshortt Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: PasswordLetterBox.py,v $
# Revision 1.1 2003/03/30 17:21:20 rshortt
# New classes: PasswordInputBox, PasswordLetterBox.
# PasswordLetterBox is a subclass of Letterbox, PasswordInputBox does not
# extend InputBox but instead is also a subclass of PopupBox. LetterBoxGroup
# has a new constructor argument called 'type' which when set to 'password'
# will make a LetterBoxGroup of PasswordLetterBox's rather than Letterbox's.
#
#
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
# 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
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ----------------------------------------------------------------------- */
#endif
import pygame
import config
from GUIObject import *
from Color import *
from Border import *
from Label import *
from LetterBox import *
from types import *
from osd import Font
DEBUG = 0
class PasswordLetterBox(LetterBox):
"""
left x coordinate. Integer
top y coordinate. Integer
width Integer
height Integer
text Letter to hold.
bg_color Background color (Color)
fg_color Foreground color (Color)
border Border
bd_color Border color (Color)
bd_width Border width Integer
"""
phoneChars = {
1 : ["1"],
2 : ["2"],
3 : ["3"],
4 : ["4"],
5 : ["5"],
6 : ["6"],
7 : ["7"],
8 : ["8"],
9 : ["9"],
0 : ["0"],
}
def __init__(self, text=" ", left=None, top=None, width=25, height=25,
bg_color=None, fg_color=None, selected_color=None,
selected_bg_color=None, selected_fg_color=None,
border=None, bd_color=None, bd_width=None):
LetterBox.__init__(self, text, left, top, width, height, bg_color,
fg_color, selected_color, selected_bg_color,
selected_fg_color, border, bd_color, bd_width)
self.real_char = ' '
def cycle_phone_char(self, command):
command = int(command)
if not self.phoneChars.has_key(command):
return
letters = self.phoneChars[command]
if letters.count(self.text) <= 0:
self.set_text(letters[0])
else:
i = letters.index(self.text)
if i < len(letters)-1:
i = i + 1
else:
i = 0
self.set_text(letters[i])
def _draw(self):
"""
The actual internal draw function.
"""
if not self.width or not self.height or not self.text:
raise TypeError, 'Not all needed variables set.'
if self.selected:
c = self.selected_bg_color.get_color_sdl()
a = self.selected_bg_color.get_alpha()
else:
c = self.bg_color.get_color_sdl()
a = self.bg_color.get_alpha()
box = pygame.Surface(self.get_size(), 0, 32)
box.fill(c)
box.set_alpha(a)
self.osd.screen.blit(box, self.get_position())
if self.selected:
self.selected_label.draw()
else:
self.label.draw()
if self.border: self.border.draw()
def get_text(self):
return self.text
def set_text(self, text):
if DEBUG: print "Text: ", text
if type(text) is StringType:
self.text = text
else:
raise TypeError, type(text)
self.real_char = text
if text != ' ':
text = '*'
if not self.label:
self.label = Label(text)
self.label.set_parent(self)
# XXX Set the background color to none so it is transparent.
self.label.set_background_color(None)
self.label.set_h_margin(self.h_margin)
self.label.set_v_margin(self.v_margin)
else:
self.label.set_text(text)
if not self.selected_label:
self.selected_label = Label(text)
self.selected_label.set_parent(self)
# XXX Set the background color to none so it is transparent.
self.selected_label.set_background_color(None)
self.selected_label.set_h_margin(self.h_margin)
self.selected_label.set_v_margin(self.v_margin)
else:
self.selected_label.set_text(text)
self.label.set_v_align(Align.MIDDLE)
self.label.set_h_align(Align.CENTER)
self.selected_label.set_v_align(Align.MIDDLE)
self.selected_label.set_h_align(Align.CENTER)
def get_font(self):
"""
Does not return OSD.Font object, but the filename and size as list.
"""
return (self.label.font.filename, self.label.font.ptsize)
def set_font(self, label, file, size, color):
"""
Set the font.
Just hands the info down to the label. Might raise an exception.
"""
label.set_font(file, size, color)
def set_border(self, bs):
"""
bs Border style to create.
Set which style to draw border around object in. If bs is 'None'
no border is drawn.
Default is to have no border.
"""
if isinstance(self.border, Border):
self.border.set_style(bs)
elif not bs:
self.border = None
else:
self.border = Border(self, bs)
def set_position(self, left, top):
"""
Overrides the original in GUIBorder to update the border as well.
"""
GUIObject.set_position(self, left, top)
if isinstance(self.border, Border):
if DEBUG: print "updating borders set_postion as well"
self.border.set_position(left, top)
def _erase(self):
"""
Erasing us from the canvas without deleting the object.
"""
if DEBUG: print " Inside PopupBox._erase..."
# Only update the part of screen we're at.
self.osd.screen.blit(self.bg_image, self.get_position(),
self.get_rect())
if self.border:
if DEBUG: print " Has border, doing border erase."
self.border._erase()
if DEBUG: print " ...", self
Index: LetterBox.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/LetterBox.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** LetterBox.py 24 Mar 2003 02:40:50 -0000 1.5
--- LetterBox.py 30 Mar 2003 17:21:17 -0000 1.6
***************
*** 10,13 ****
--- 10,20 ----
# -----------------------------------------------------------------------
# $Log$
+ # Revision 1.6 2003/03/30 17:21:17 rshortt
+ # New classes: PasswordInputBox, PasswordLetterBox.
+ # PasswordLetterBox is a subclass of Letterbox, PasswordInputBox does not
+ # extend InputBox but instead is also a subclass of PopupBox. LetterBoxGroup
+ # has a new constructor argument called 'type' which when set to 'password'
+ # will make a LetterBoxGroup of PasswordLetterBox's rather than Letterbox's.
+ #
# Revision 1.5 2003/03/24 02:40:50 rshortt
# These objects are now using skin properties.
***************
*** 95,108 ****
phoneChars = {
! 1 : ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
! 2 : ["A", "B", "C"],
! 3 : ["D", "E", "F"],
! 4 : ["G", "H", "I"],
! 5 : ["J", "K", "L"],
! 6 : ["M", "N", "O"],
! 7 : ["P", "Q", "R", "S"],
! 8 : ["T", "U", "V"],
! 9 : ["W", "X", "Y", "Z"],
! 0 : ["-", " "],
}
--- 102,115 ----
phoneChars = {
! 1 : ["1"],
! 2 : ["2", "A", "B", "C"],
! 3 : ["3", "D", "E", "F"],
! 4 : ["4", "G", "H", "I"],
! 5 : ["5", "J", "K", "L"],
! 6 : ["6", "M", "N", "O"],
! 7 : ["7", "P", "Q", "R", "S"],
! 8 : ["8", "T", "U", "V"],
! 9 : ["9", "W", "X", "Y", "Z"],
! 0 : ["0", "-", " "],
}
Index: LetterBoxGroup.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/LetterBoxGroup.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** LetterBoxGroup.py 30 Mar 2003 16:15:42 -0000 1.5
--- LetterBoxGroup.py 30 Mar 2003 17:21:19 -0000 1.6
***************
*** 11,14 ****
--- 11,21 ----
# -----------------------------------------------------------------------
# $Log$
+ # Revision 1.6 2003/03/30 17:21:19 rshortt
+ # New classes: PasswordInputBox, PasswordLetterBox.
+ # PasswordLetterBox is a subclass of Letterbox, PasswordInputBox does not
+ # extend InputBox but instead is also a subclass of PopupBox. LetterBoxGroup
+ # has a new constructor argument called 'type' which when set to 'password'
+ # will make a LetterBoxGroup of PasswordLetterBox's rather than Letterbox's.
+ #
# Revision 1.5 2003/03/30 16:15:42 rshortt
# Got rid of trailing whitespaces from the 'word'.
***************
*** 61,71 ****
import config
! from GUIObject import *
! from Color import *
! from Border import *
! from Label import *
! from LetterBox import *
! from types import *
! from osd import Font
DEBUG = 0
--- 68,79 ----
import config
! from GUIObject import *
! from Color import *
! from Border import *
! from Label import *
! from LetterBox import *
! from PasswordLetterBox import *
! from types import *
! from osd import Font
DEBUG = 0
***************
*** 88,98 ****
! def __init__(self, numboxes=7, text=None, handler=None, left=None, top=None,
! width=None, height=None, bg_color=None, fg_color=None,
! border=None, bd_color=None, bd_width=None):
# XXX: text not supported yet
self.text = text
self.handler = handler
self.bg_color = bg_color
self.fg_color = fg_color
--- 96,107 ----
! def __init__(self, numboxes=7, text=None, handler=None, type=None,
! left=None, top=None, width=None, height=None, bg_color=None,
! fg_color=None, border=None, bd_color=None, bd_width=None):
# XXX: text not supported yet
self.text = text
self.handler = handler
+ self.type = type
self.bg_color = bg_color
self.fg_color = fg_color
***************
*** 140,144 ****
h = 0
for i in range(self.numboxes):
! lb = LetterBox()
l = l + lb.width
if lb.height > h: h = lb.height
--- 149,156 ----
h = 0
for i in range(self.numboxes):
! if self.type == 'password':
! lb = PasswordLetterBox()
! else:
! lb = LetterBox()
l = l + lb.width
if lb.height > h: h = lb.height
***************
*** 190,194 ****
word = ''
for box in self.boxes:
! word = word + box.get_text()
return word.rstrip()
--- 202,209 ----
word = ''
for box in self.boxes:
! if isinstance(self.border, PasswordLetterBox):
! word += box.real_char
! else:
! word = word + box.get_text()
return word.rstrip()
Index: __init__.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/__init__.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** __init__.py 24 Feb 2003 11:58:28 -0000 1.5
--- __init__.py 30 Mar 2003 17:21:20 -0000 1.6
***************
*** 20,23 ****
--- 20,30 ----
#-----------------------------------------------------------------------
# $Log$
+ # Revision 1.6 2003/03/30 17:21:20 rshortt
+ # New classes: PasswordInputBox, PasswordLetterBox.
+ # PasswordLetterBox is a subclass of Letterbox, PasswordInputBox does not
+ # extend InputBox but instead is also a subclass of PopupBox. LetterBoxGroup
+ # has a new constructor argument called 'type' which when set to 'password'
+ # will make a LetterBoxGroup of PasswordLetterBox's rather than Letterbox's.
+ #
# Revision 1.5 2003/02/24 11:58:28 rshortt
# Adding OptionBox and optiondemo. Also some minor cleaning in a few other
***************
*** 110,130 ****
import os.path
! from gui.Border import *
! from gui.Color import *
! from gui.GUIObject import *
! from gui.PopupBox import *
! from gui.AlertBox import *
! from gui.ConfirmBox import *
! from gui.Label import *
! from gui.Button import *
! from gui.LetterBox import *
! from gui.LetterBoxGroup import *
! from gui.RegionScroller import *
! from gui.Scrollbar import *
! from gui.InputBox import *
! from gui.exceptions import *
! from gui.scrolldemo import *
! from gui.listboxdemo import *
! from gui.optiondemo import *
--- 117,139 ----
import os.path
! from gui.Border import *
! from gui.Color import *
! from gui.GUIObject import *
! from gui.PopupBox import *
! from gui.AlertBox import *
! from gui.ConfirmBox import *
! from gui.Label import *
! from gui.Button import *
! from gui.LetterBox import *
! from gui.PasswordLetterBox import *
! from gui.LetterBoxGroup import *
! from gui.RegionScroller import *
! from gui.Scrollbar import *
! from gui.InputBox import *
! from gui.PasswordInputBox import *
! from gui.exceptions import *
! from gui.scrolldemo import *
! from gui.listboxdemo import *
! from gui.optiondemo import *
-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog