import uiconfig, runtime
import utils
from roxiadebug import *
ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT = 0, 1, 2
VALIGN_TOP, VALIGN_CENTER, VALIGN_BOTTOM = 11, 12, 13
class Widget(object):
def __init__(self):
self.children = []
self.hidden = False
def hide(self):
self.hidden = True
for w in self.children:
w.hide()
def show(self):
self.hidden = False
for w in self.children:
w.show()
def free(self):
for w in self.children:
w.free()
class CallbackWidget(Widget):
def __init__(self):
Widget.__init__(self)
self.callbacks = {}
def free(self):
Widget.free(self)
self.callbacks = {}
def add_callback(self, name, cb):
cbs = self.callbacks.get(name)
if cbs:
cbs.append(cb)
else:
self.callbacks[name] = [cb]
def del_callback(self, name, cb):
cbs = self.callbacks.get(name)
for i, c in enumerate(cbs):
if c == cb:
del cbs[i]
def run_callback(self, name, *ev_data):
cbs = self.callbacks.get(name)
if not cbs or cbs == [None]:
print 'cancel->',cbs
return
print cbs
for cb in cbs:
cb(*ev_data)
#thang [20080315] -2 setup line,icont, scroll line for 2 depth
class List(Widget):
# start shchun : add additional argument, x, numcol May-11
def __init__(self, labels, unselbarpos=[], x = uiconfig.list_pos_x, num_col=True):
# end shchun
self.unselbarpos = unselbarpos
import status
Widget.__init__(self)
self.icon_columns = []
self.up_arrow = None
self.down_arrow = None
# start shchun : add additional argument, x, numcol May-11
self.num_col = num_col
# end shchun
self.labels = []
for lst in labels:
self.labels.append(utils.get_real_lang_str(lst))
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.items = []
self.focus = -1
self.prev_focus = -1
self.nrow = nrow = len(self.labels)
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.list_pos_y1
elif nrow == 2: pos_y = uiconfig.list_pos_y2
elif nrow == 3: pos_y = uiconfig.list_pos_y3
elif nrow == 4: pos_y = uiconfig.list_pos_y4
elif nrow == 5: pos_y = uiconfig.list_pos_y5
else: pos_y = uiconfig.list_pos_y6
# start shchun : add additional argument, x, numcol May-11
#x = uiconfig.list_pos_x
# end shchun
self.pos_y = pos_y
for i, y in enumerate(pos_y):
#image = utils.put_image(uiconfig.current_theme.unselected_bar, (223, y-8), (218, 40)) # KA: [20080320] Temporary Set
#image = utils.put_image(uiconfig.current_theme.unselected_bar, (223, y-2), (220, 40))
#image = utils.put_image(uiconfig.current_theme.unselected_bar, (225, y-2), (222, 40))
image = utils.put_image(uiconfig.current_theme.unselected_bar, (230, y-2), (222, 40)) # shchun : no scaling for IP3870M
image.hide()
pos = x + uiconfig.list_pos_text_delta_x, y + uiconfig.list_pos_text_delta_y
if status.phonebook_emergency and i==0 and status.phonebook_isempty:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
elif status.phonebook_emergency and i==0:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
else:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
self.items.append((image,text))
self.children.append(image)
self.children.append(text)
for y in uiconfig.underbar_pos_y:
underbar = utils.put_image(uiconfig.under_bar, (uiconfig.underbar_pos_x, y))
underbar.hide()
self.children.append(underbar)
if nrow > 6: # draw scroll arrow
self.up_arrow = utils.put_image(uiconfig.up_arrow, uiconfig.list_up_arrow_pos)
self.up_arrow.hide()
self.down_arrow = utils.put_image(uiconfig.down_arrow, uiconfig.list_down_arrow_pos, (6,int(198/len(self.labels))))
self.down_arrow.hide()
self.children.append(self.up_arrow)
self.children.append(self.down_arrow)
self.set_focus(0)
#---------------------------------
# List Item 이 선택되었음
#---------------------------------
def set_focus(self, focus):
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
self.remove_item_scroll_timer()
if self.focus >= 0:
image,text = self.items[self.focus - self.top_index]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
# OLD/NEW item text
hi_index = focus - self.top_index
# 스크롤이 화면범위를 벗어나 update가 필요한 경우
if hi_index < 0 or len(uiconfig.list_pos_y6) <= hi_index:
if hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.list_pos_y6) + 1
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(uiconfig.list_pos_y6)):
image,text = self.items[i]
text.set_text( self.labels[self.top_index + i] )
if status.phonebook_emergency and i==0 and status.phonebook_isempty:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
elif status.phonebook_emergency and self.top_index == 0 and i == 0:# and len(self.labels) > 1:
text.set_color(uiconfig.list_text_emergency_color)
else:
text.set_color(uiconfig.list_text_color)
else:
# prev item을 다시 그림
# 글자가 긴 경우 잘라서(blabla...)그림
if selected_olditem:
old_image,old_text = self.items[self.focus - self.top_index]
old_image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
old_text.set_text(self.labels[self.focus])
old_text.set_color(uiconfig.list_text_color)
self.focus = focus
image,text = self.items[focus - self.top_index]
#thang [20080317-3] update icon
text.set_color(uiconfig.color_white)
'''
print "[yylee debug] Widget:[%d:%d:%d]"%(focus, self.prev_focus, self.top_index)
if self.prev_focus >= 0 and self.prev_focus != self.focus :
if self.prev_focus - self.top_index < 6:
if self.focus - self.prev_focus < 2:
prev_image,prev_text = self.items[self.prev_focus - self.top_index]
prev_text.set_color(uiconfig.list_text_color)
'''
# start shchun : add additional argument, x, numcol May-11
# if self.num_col is true, number icon will show.
#if self.num_col:
if 0: # disable this routine because of trying to cut down MMI delay time
print focus
for ic in self.icon_columns:
index = 0
while index < len(self.labels):
ic.set_icon(index, uiconfig.list_icon_cnt[index])
index += 1
ic.set_icon(focus,uiconfig.list_icon_cnt_r[focus])
''''
if focus == 0:
len(self.labels) > 10
ic.set_icon(len(self.labels) - 1,uiconfig.list_icon_cnt[len(self.labels) - 1])
ic.set_icon(focus,uiconfig.list_icon_cnt_r[focus])
ic.set_icon(focus + 1,uiconfig.list_icon_cnt[focus + 1])
elif focus >0 and focus < len(self.labels) - 1:
ic.set_icon(0,uiconfig.list_icon_cnt[0])
ic.set_icon(focus - 1,uiconfig.list_icon_cnt[focus -1])
ic.set_icon(focus,uiconfig.list_icon_cnt_r[focus])
ic.set_icon(focus + 1,uiconfig.list_icon_cnt[focus + 1])
elif focus == len(self.labels) - 1:
ic.set_icon(focus - 1,uiconfig.list_icon_cnt[focus -1])
ic.set_icon(focus,uiconfig.list_icon_cnt_r[focus])
ic.set_icon(0,uiconfig.list_icon_cnt[0])
'''
# end shchun
#thang [20080317-3] update icon
if len(self.labels) > 6:
#self.down_arrow.move(uiconfig.list_down_arrow_pos[0],int(200/len(self.labels)) + self.focus * int(200/len(self.labels)) + 6) # jhkim
# self.down_arrow.move(uiconfig.list_down_arrow_pos[0],int(198/len(self.labels)) + self.focus * int(198/len(self.labels)) )
#self.down_arrow.move(uiconfig.list_down_arrow_pos[0],uiconfig.list_down_arrow_pos[1] + int(self.focus * float(198.0/len(self.labels))) )
#self.down_arrow.move(uiconfig.list_down_arrow_pos[0],uiconfig.list_down_arrow_pos[1] + int(self.focus * float(198.0/len(self.labels))) )#self.down_arrow.move(uiconfig.list_down_arrow_pos[0],uiconfig.list_down_arrow_pos[1] + int(self.focus * float(198.0/len(self.labels))) )
self.down_arrow.move(uiconfig.list_down_arrow_pos[0],uiconfig.list_down_arrow_pos[1] + int(self.focus * float((198.0-30.0)/len(self.labels))) )
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_selection
def scroll_item_timer_cb():
try:
# KA: [20070921] this conversion is required for Korean text
#if ord(self.temp_text[0]) > 127:
latin_char = True
if type(self.temp_text) == type('abc'):
self.temp_text = unicode(self.temp_text, 'utf-8')[1:]
else:
self.temp_text = self.temp_text[1:]
self.temp_text = self.temp_text.encode('utf-8')
except:
self.temp_text = ''
if len(self.temp_text) == 0:
self.temp_text = self.org_label
abbr_text = set_scroll_text(self.temp_text, uiconfig.item_width_scroll)
self.scroll_text.set_text(abbr_text, False)
runtime.evas.render()
return True
def set_scroll_text(item_text, abbr_width):
if abbr_width > 0:
abbr_text = utils.cut_text(item_text, abbr_width, uiconfig.list_font)[0]
return abbr_text
else:
return item_text
def is_scroll_item(item_text):
etext = runtime.evas.text(text=item_text, font=uiconfig.list_font, color=uiconfig.list_text_color)
text_width = etext.geometry[2]
etext.free()
if text_width > uiconfig.item_width_scroll:
return True
else:
return False
#스크롤 할지를 결정
if is_scroll_item(self.labels[focus]) == True:
self.org_label = self.temp_text = self.labels[self.focus]
item_text = set_scroll_text(self.temp_text, uiconfig.item_width_scroll)
text.set_text(item_text)
self.scroll_text = text
self.item_scroll_timer = utils.Timer(400, scroll_item_timer_cb)
else:
text.set_text(self.labels[self.focus])
self.prev_focus = self.focus
def remove_item_scroll_timer(self):
if self.item_scroll_timer:
del(self.item_scroll_timer)
self.item_scroll_timer = None
self.scroll_text = None
self.temp_text = None
def show(self):
self.set_focus(self.focus)
Widget.show(self)
def hide(self):
self.remove_item_scroll_timer()
Widget.hide(self)
def free(self):
self.remove_item_scroll_timer()
Widget.free(self)
def set_init_focus(self, focus, top_index):
if self.nrow == 0:
return
self.focus = focus
self.top_index = top_index
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(self.items)):
image, text = self.items[i]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
text.set_text( self.labels[self.top_index + i] )
image, text = self.items[focus - self.top_index]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_selection
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def set_text(self, n, text):
roxia_trace('**** List.set_text(), n=', n, 'text=', text)
if type(self.labels) == type((0,)):
self.labels = list(self.labels)
self.labels[n] = text
vindex = n - self.top_index
if 0 <= vindex < len(self.pos_y):
r, t = self.items[vindex]
t.set_text(text)
def change_language(self):
for i in range(len(self.pos_y)):
r, t = self.items[i]
t.set_text('')
t.set_text( self.labels[i + self.top_index] )
def attach_icon_column(self, ic):
self.icon_columns.append(ic)
def remove_all_icon_columns(self):
self.icon_columns = []
def update_icon_index(self):
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
class WorldTimeList(Widget):
def __init__(self, labels, unselbarpos=[]):
self.unselbarpos = unselbarpos
import status
Widget.__init__(self)
self.icon_columns = []
self.labels = []
for lst in labels:
self.labels.append(utils.get_real_lang_str(lst))
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.items = []
self.focus = -1
#self.yparam1 = 200
self.yparam1 = 197
#self.yparam2 = (len(self.labels) + 1)
self.yparam2 = len(self.labels)
print '### self.yparam_1', self.yparam1, self.yparam2
self.nrow = nrow = len(self.labels)
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.list2_pos_y1
elif nrow == 2: pos_y = uiconfig.list2_pos_y2
elif nrow == 3: pos_y = uiconfig.list2_pos_y3
elif nrow == 4: pos_y = uiconfig.list2_pos_y4
elif nrow == 5: pos_y = uiconfig.list2_pos_y5
else: pos_y = uiconfig.list2_pos_y6
x = uiconfig.list2_pos_x
self.pos_y = pos_y
for i, y in enumerate(pos_y):
image = utils.put_image(uiconfig.current_theme.unselected_bar, (9,y), (460,32)) # KA: [20080320] Temporary Set
image.hide()
#pos = x + uiconfig.list2_pos_text_delta_x, y + uiconfig.list2_pos_text_delta_y
pos = x , y + uiconfig.list2_pos_text_delta_y
text = WorldTimeListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
self.items.append((image,text))
self.children.append(image)
self.children.append(text)
for y in uiconfig.underbar1_pos_y:
underbar = utils.put_image(uiconfig.under_bar, (uiconfig.underbar1_pos_x,y), (440,2))
underbar.hide()
self.children.append(underbar)
if nrow > 6: # draw scroll arrow
self.scroll_bg = utils.put_image(uiconfig.scroll_bg, uiconfig.scroll_bg_pos)
self.scroll_bg.hide()
#self.scroll_bar = utils.put_image(uiconfig.scroll_bar, (467,44), (4,int(197/len(self.labels))))
#self.scroll_bar = utils.put_image(uiconfig.scroll_bar, (467,44+1), (4,int(197/len(self.labels))))
self.scroll_bar = utils.put_image(uiconfig.scroll_bar, (467,44+1), (4,self.yparam1/self.yparam2))
#int(197/len(self.labels)))
self.scroll_bar.hide()
self.children.append(self.scroll_bg)
self.children.append(self.scroll_bar)
self.set_focus(0)
def set_focus(self, focus):
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
if self.focus >= 0:
image,text = self.items[self.focus - self.top_index]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
# OLD/NEW item text
hi_index = focus - self.top_index
# 스크롤이 화면범위를 벗어나 update가 필요한 경우
if hi_index < 0 or len(uiconfig.list_pos_y6) <= hi_index:
if hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.list2_pos_y6) + 1
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(uiconfig.list2_pos_y6)):
image,text = self.items[i]
text.set_text( self.labels[self.top_index + i])
text.set_color(uiconfig.list_text_color)
else:
# prev item을 다시 그림
# 글자가 긴 경우 잘라서(blabla...)그림
if selected_olditem:
old_image,old_text = self.items[self.focus - self.top_index]
old_image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
old_text.set_text(self.labels[self.focus])
self.focus = focus
image,text = self.items[focus - self.top_index]
print focus
if len(self.labels) > 6:
#self.scroll_bar.move(467, int(197/len(self.labels)) + self.focus* int(197/len(self.labels)) + 43 - int(197/len(self.labels)) )
#self.scroll_bar.move(467, int(self.focus*(197/len(self.labels)+1)*0.98) + 44+1)
if self.focus == len(self.labels) -1:
self.scroll_bar.move(467, 197 - (197/len(self.labels)) + 44+1)
else:
self.scroll_bar.move(467, int(float(self.focus)*float(197.0/len(self.labels))) + 44+1)
#uiconfig.scroll_bar_pos[0]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
#image.file = uiconfig.image_dir + uiconfig.current_theme.menu_selection
image.file = uiconfig.image_dir + uiconfig.menu_selection
def show(self):
self.set_focus(self.focus)
Widget.show(self)
def hide(self):
Widget.hide(self)
def free(self):
Widget.free(self)
def set_init_focus(self, focus, top_index):
if self.nrow == 0:
return
self.focus = focus
self.top_index = top_index
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(self.items)):
image, text = self.items[i]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
text.set_text( self.labels[self.top_index + i] )
image, text = self.items[focus - self.top_index]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + menu_selection
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def set_text(self, n, text):
roxia_trace('**** List.set_text(), n=', n, 'text=', text)
if type(self.labels) == type((0,)):
self.labels = list(self.labels)
self.labels[n] = text
vindex = n - self.top_index
if 0 <= vindex < len(self.pos_y):
r, t = self.items[vindex]
t.set_text(text)
def change_language(self):
for i in range(len(self.pos_y)):
r, t = self.items[i]
t.set_text('')
t.set_text( self.labels[i + self.top_index] )
def attach_icon_column(self, ic):
self.icon_columns.append(ic)
def remove_all_icon_columns(self):
self.icon_columns = []
def update_icon_index(self):
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
class CalendarList(Widget):
def __init__(self, labels, unselbarpos=[], x=uiconfig.list2_pos_x):
self.unselbarpos = unselbarpos
self.x = x
import status
Widget.__init__(self)
self.icon_columns = []
self.labels = []
for lst in labels:
self.labels.append(utils.get_real_lang_str(lst))
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.items = []
self.focus = -1
self.yparam1 = 200
#self.yparam2 = (len(self.labels) + 1)
self.yparam2 = (len(self.labels))
print '### self.yparam', self.yparam1, self.yparam2
self.nrow = nrow = len(self.labels)
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.list2_pos_y1
elif nrow == 2: pos_y = uiconfig.list2_pos_y2
elif nrow == 3: pos_y = uiconfig.list2_pos_y3
elif nrow == 4: pos_y = uiconfig.list2_pos_y4
elif nrow == 5: pos_y = uiconfig.list2_pos_y5
else: pos_y = uiconfig.list2_pos_y6
#x = uiconfig.list2_pos_x
self.pos_y = pos_y
for i, y in enumerate(pos_y):
image = utils.put_image(uiconfig.current_theme.unselected_bar, (9,y), (460,33)) # KA: [20080320] Temporary Set
image.hide()
#pos = x + uiconfig.list2_pos_text_delta_x, y + uiconfig.list2_pos_text_delta_y
pos = x, y+12
text = WorldTimeListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
self.items.append((image,text))
self.children.append(image)
self.children.append(text)
for y in uiconfig.underbar1_pos_y:
underbar = utils.put_image(uiconfig.under_bar, (uiconfig.underbar1_pos_x, y), (440,2))
underbar.hide()
self.children.append(underbar)
if nrow > 6: # draw scroll arrow
self.scroll_bg = utils.put_image(uiconfig.scroll_bg, uiconfig.scroll_bg_pos)
self.scroll_bg.hide()
#self.scroll_bar = utils.put_image(uiconfig.scroll_bar, (467,44), (4,int(197/len(self.labels))))
self.scroll_bar = utils.put_image(uiconfig.scroll_bar, (467,44), (4,self.yparam1/self.yparam2))
print '### SIZE', self.yparam1/self.yparam2
#int(197/len(self.labels)))
self.scroll_bar.hide()
self.children.append(self.scroll_bg)
self.children.append(self.scroll_bar)
self.set_focus(0)
def set_focus(self, focus):
#print 'ka....1.focus=', focus
#print 'ka....self.nrow=', self.nrow
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
#print 'ka....2focus=', focus
if self.focus >= 0:
image,text = self.items[self.focus - self.top_index]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
# OLD/NEW item text
hi_index = focus - self.top_index
# 스크롤이 화면범위를 벗어나 update가 필요한 경우
if hi_index < 0 or len(uiconfig.list_pos_y6) <= hi_index:
if hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.list2_pos_y6) + 1
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(uiconfig.list2_pos_y6)):
image,text = self.items[i]
text.set_text( self.labels[self.top_index + i] )
text.set_color(uiconfig.list_text_color)
else:
# prev item을 다시 그림
# 글자가 긴 경우 잘라서(blabla...)그림
if selected_olditem:
old_image,old_text = self.items[self.focus - self.top_index]
old_image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
old_text.set_text(self.labels[self.focus])
self.focus = focus
image,text = self.items[focus - self.top_index]
print focus
if len(self.labels) > 6:
#self.scroll_bar.move(467,int(197/len(self.labels)) + self.focus * int(197/len(self.labels))+ 43 - int(197/len(self.labels)) )
self.scroll_bar.move(467, self.focus * self.yparam1 /self.yparam2 + 43)
print '#### FOCUS', self.focus, self.focus * self.yparam1 /self.yparam2 + 43
#uiconfig.scroll_bar_pos[0]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
#image.file = uiconfig.image_dir + uiconfig.current_theme.menu_selection
image.file = uiconfig.image_dir + uiconfig.menu_selection
def show(self):
self.set_focus(self.focus)
Widget.show(self)
def hide(self):
Widget.hide(self)
def free(self):
Widget.free(self)
def set_init_focus(self, focus, top_index):
if self.nrow == 0:
return
self.focus = focus
self.top_index = top_index
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(self.items)):
image, text = self.items[i]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
text.set_text( self.labels[self.top_index + i] )
image, text = self.items[focus - self.top_index]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + menu_selection
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def set_text(self, n, text):
roxia_trace('**** List.set_text(), n=', n, 'text=', text)
if type(self.labels) == type((0,)):
self.labels = list(self.labels)
self.labels[n] = text
vindex = n - self.top_index
if 0 <= vindex < len(self.pos_y):
r, t = self.items[vindex]
t.set_text(text)
def change_language(self):
for i in range(len(self.pos_y)):
r, t = self.items[i]
t.set_text('')
t.set_text( self.labels[i + self.top_index] )
def attach_icon_column(self, ic):
self.icon_columns.append(ic)
def remove_all_icon_columns(self):
self.icon_columns = []
def update_icon_index(self):
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
# KA: [20080311] phonebook UI
class PhoneBookList(Widget):
def __init__(self, labels, unselbarpos=[]):
self.unselbarpos = unselbarpos
import status
Widget.__init__(self)
self.icon_columns = []
self.scroll_bg = None
self.scroll_ball = None
self.labels = []
for lst in labels:
self.labels.append(utils.get_real_lang_str(lst))
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.items = []
self.focus = -1
x = uiconfig.pb_list_pos_x
self.nrow = nrow = len(self.labels)
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.pb_list_pos_y1
elif nrow == 2: pos_y = uiconfig.pb_list_pos_y2
elif nrow == 3: pos_y = uiconfig.pb_list_pos_y3
elif nrow == 4: pos_y = uiconfig.pb_list_pos_y4
else: pos_y = uiconfig.pb_list_pos_y5
# x = uiconfig.list_pos_x
self.pos_y = pos_y
for i, y in enumerate(pos_y):
image = utils.put_image(uiconfig.current_theme.unselected_bar, (uiconfig.pb_underbar_pos_x,y - uiconfig.list_pos_text_delta_y-9), (221, 38))
image.hide()
pos = x , y - uiconfig.list_pos_text_delta_y
if status.phonebook_emergency and i==0 and status.phonebook_isempty:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
elif status.phonebook_emergency and i==0:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
else:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
self.items.append((image, text))
self.children.append(image)
self.children.append(text)
for y in uiconfig.pb_underbar_pos_y:
underbar = utils.put_image(uiconfig.under_bar, (uiconfig.pb_underbar_pos_x, y))
underbar.hide()
self.children.append(underbar)
if nrow > 5: # draw scroll arrow
self.scroll_bg = utils.put_image('scroll_bg.png',(424,77),(4, 162))
print self.scroll_bg
self.scroll_bg.hide()
if len(self.labels) <=40:
self.scroll_ball = utils.put_image('scroll_ball.png',(424,78),(4,int(162/len(self.labels))))
else:
self.scroll_ball = utils.put_image('scroll_ball.png',(424,78),(4,4))
self.scroll_bg.hide()
self.children.append(self.scroll_bg)
self.children.append(self.scroll_ball)
# self.set_focus(0)
#---------------------------------
# List Item 이 선택되었음
#---------------------------------
def set_focus(self, focus):
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
self.remove_item_scroll_timer()
if self.focus >= 0:
image, text = self.items[self.focus - self.top_index]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
# OLD/NEW item text
hi_index = focus - self.top_index
# 스크롤이 화면범위를 벗어나 update가 필요한 경우
if hi_index < 0 or len(uiconfig.pb_list_pos_y5) <= hi_index:
if hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.pb_list_pos_y5) + 1
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(uiconfig.pb_list_pos_y5)):
image, text = self.items[i]
text.set_text( self.labels[self.top_index + i] )
if status.phonebook_emergency and i==0 and status.phonebook_isempty:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
elif status.phonebook_emergency and self.top_index == 0 and i == 0:# and len(self.labels) > 1:
text.set_color(uiconfig.list_text_emergency_color)
else:
text.set_color(uiconfig.list_text_color)
else:
# prev item을 다시 그림
# 글자가 긴 경우 잘라서(blabla...)그림
if selected_olditem:
old_image, old_text, = self.items[self.focus - self.top_index]
old_image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
old_text.set_text(self.labels[self.focus])
self.focus = focus
image, text = self.items[focus - self.top_index]
if len(self.labels) > 5:
#self.scroll_ball.move(424,int(162/len(self.labels)) + self.focus * int(162/len(self.labels)) + 77 - int(162/len(self.labels)) )
self.scroll_ball.move(424, int((162.0/len(self.labels)) + self.focus * (162.0/len(self.labels)) + 77 - (162.0/len(self.labels))) )
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_selection
# phone number update
def scroll_item_timer_cb():
try:
# KA: [20070921] this conversion is required for Korean text
#if ord(self.temp_text[0]) > 127:
latin_char = True
#self.temp_text = self.temp_text[2:]
#self.temp_text = (unicode(self.temp_text, 'utf-8')[1:]).encode('utf-8')
if type(self.temp_text) == type('abc'):
self.temp_text = unicode(self.temp_text, 'utf-8')[1:]
else:
self.temp_text = self.temp_text[1:]
self.temp_text = self.temp_text.encode('utf-8')
#else:
# latin_char = False
# self.temp_text = self.temp_text[1:]
except:
self.temp_text = ''
if len(self.temp_text) == 0:
self.temp_text = self.org_label
abbr_text = set_scroll_text(self.temp_text, uiconfig.item_width_scroll)
self.scroll_text.set_text(abbr_text, False)
runtime.evas.render()
return True
def set_scroll_text(item_text, abbr_width):
if abbr_width > 0:
abbr_text = utils.cut_text(item_text, abbr_width, uiconfig.list_font)[0]
return abbr_text
else:
return item_text
def is_scroll_item(item_text):
etext = runtime.evas.text(text=item_text, font=uiconfig.list_font, color=uiconfig.list_text_color)
text_width = etext.geometry[2]
etext.free()
if text_width > uiconfig.item_width_scroll:
return True
else:
return False
#스크롤 할지를 결정
if is_scroll_item(self.labels[focus]) == True:
self.org_label = self.temp_text = self.labels[self.focus]
item_text = set_scroll_text(self.temp_text, uiconfig.item_width_scroll)
text.set_text(item_text)
self.scroll_text = text
self.item_scroll_timer = utils.Timer(400, scroll_item_timer_cb)
else:
text.set_text(self.labels[self.focus])
def remove_item_scroll_timer(self):
if self.item_scroll_timer:
del(self.item_scroll_timer)
self.item_scroll_timer = None
self.scroll_text = None
self.temp_text = None
def show(self):
self.set_focus(self.focus)
Widget.show(self)
def hide(self):
self.remove_item_scroll_timer()
Widget.hide(self)
def free(self):
self.remove_item_scroll_timer()
Widget.free(self)
def set_init_focus(self, focus, top_index):
if self.nrow == 0:
return
self.focus = focus
self.top_index = top_index
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(self.items)):
image, text = self.items[i]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
text.set_text( self.labels[self.top_index + i] )
image, text = self.items[focus - self.top_index]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_selection
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def set_text(self, n, text):
roxia_trace('**** List.set_text(), n=', n, 'text=', text)
if type(self.labels) == type((0,)):
self.labels = list(self.labels)
self.labels[n] = text
vindex = n - self.top_index
if 0 <= vindex < len(self.pos_y):
r, t = self.items[vindex]
t.set_text(text)
def change_language(self):
for i in range(len(self.pos_y)):
r, t = self.items[i]
t.set_text('')
t.set_text( self.labels[i + self.top_index] )
def attach_icon_column(self, ic):
self.icon_columns.append(ic)
def remove_all_icon_columns(self):
self.icon_columns = []
def update_icon_index(self):
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
# KA: [20080311] Phonebook UI ==
#thang[20080422-1]
class AddPhoneBook(Widget):
def __init__(self, frame, unselbarpos=[]):
self.unselbarpos = unselbarpos
import status
Widget.__init__(self)
self.icon_columns = []
self.scroll_bg = None
self.scroll_ball = None
self.choose = (_('Name'),_('Group'),_('Home'),_('Mobile'),_('Office'),_('Speed'),_('Email'),_('Bell'),'',_('Image'),'','')
self.icons = []
self.labels = []
self.entrys = []
for lst in frame:
self.icons.append(lst[0])
self.labels.append(lst[1])
self.entrys.append(lst[2])
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.focus = -1
x = uiconfig.pb_entry_pos_x
self.nrow = nrow = len(self.labels)
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.pb_entry_pos_y1
elif nrow == 2: pos_y = uiconfig.pb_entry_pos_y2
elif nrow == 3: pos_y = uiconfig.pb_entry_pos_y3
elif nrow == 4: pos_y = uiconfig.pb_entry_pos_y4
elif nrow == 5: pos_y = uiconfig.pb_entry_pos_y5
else: pos_y = uiconfig.pb_entry_pos_y6
# x = uiconfig.list_pos_x
self.pos_y = pos_y
i =0
while i < len(self.labels):
self.children.append(self.icons[i])
self.children.append(self.labels[i])
self.children.append(self.entrys[i])
i += 1
for i, y in enumerate(pos_y):
self.icons[i].setPosition(uiconfig.input6p_x1, y+4)
if i not in [8,10,11]:
self.icons[i].show()
self.labels[i].set_position(uiconfig.input6p_x2, y+16-uiconfig.input_font[1]/2-2)
self.labels[i].set_text(self.choose[i])
self.labels[i].show()
self.entrys[i].setPosition(uiconfig.input6p_x3, y)
self.entrys[i].show()
if nrow > 6: # draw scroll arrow
self.scroll_bg = utils.put_image('scroll_bg.png',(444,45),(4, 192))
self.scroll_bg.hide()
self.scroll_ball = utils.put_image('scroll_ball.png',(444,47),(4,int(192/len(self.labels))))
self.scroll_bg.hide()
self.children.append(self.scroll_bg)
self.children.append(self.scroll_ball)
def set_focus(self, focus, new=False):
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
hi_index = focus - self.top_index
#print 'ka...............focus=', focus
#print 'ka...............top_index=', self.top_index
#print 'ka...............hi_index=', hi_index
#if hi_index < 0 or len(self.pos_y) <= hi_index or focus == 9:
#print 'ka.......... len(self.pos_y) =', len(self.pos_y)
if hi_index < 0 or len(self.pos_y) <= hi_index or focus == 9 or (new == True and self.top_index > 0):
#print 'ka...........ENTER'
if focus in [9,10]:
hi_index = focus
self.top_index = 9
elif focus == 8:
hi_index = focus
self.top_index = 3
elif focus < 6:
hi_index = 0
self.top_index = 0
elif hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.list_pos_y6) + 1
#print '========', self.top_index,hi_index,focus
i =0
while i < len(self.labels):
self.icons[i].hide()
self.labels[i].hide()
self.entrys[i].hide()
i += 1
x = uiconfig.pb_entry_pos_x
for i, y in enumerate(self.pos_y):
if (i + self.top_index) < len(self.choose):
self.icons[i+self.top_index].setPosition(uiconfig.input6p_x1, y+4)
if (i+self.top_index) not in [8,10,11]:
self.icons[i+self.top_index].show()
self.labels[i+self.top_index].set_position(uiconfig.input6p_x2, y+16-uiconfig.input_font[1]/2-2)
self.labels[i+self.top_index].set_text(self.choose[i+self.top_index])
self.labels[i+self.top_index].show()
if (i + self.top_index) == len(self.choose) - 1:
self.entrys[i+self.top_index].setPosition(uiconfig.input6p_x3+70, y)
self.entrys[i+self.top_index].show()
else:
self.entrys[i+self.top_index].setPosition(uiconfig.input6p_x3, y)
self.entrys[i+self.top_index].show()
#print 'ka..........END top=', self.top_index
self.focus = focus
if len(self.labels) > 6:
self.scroll_ball.move(444, int(192/len(self.labels)) + self.focus * int(192/len(self.labels)) + 47 - int(192/len(self.labels)) )
def get_focus(self):
return self.focus
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 2)
def focus_down(self):
if self.focus < len(self.labels) - 2:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def show(self):
#self.set_focus(self.focus)
Widget.show(self)
i =6
while i < len(self.labels):
self.icons[i].hide()
self.labels[i].hide()
self.entrys[i].hide()
i += 1
def hide(self):
#self.remove_item_scroll_timer()
Widget.hide(self)
def free(self):
#self.remove_item_scroll_timer()
Widget.free(self)
#---------------------------------
# List Item 이 선택되었음
# KA: [30080429] other way
class GroupEdit(Widget):
def __init__(self, frame, unselbarpos=[]):
self.unselbarpos = unselbarpos
import status
Widget.__init__(self)
self.icon_columns = []
self.scroll_bg = None
self.scroll_ball = None
self.choose = ('Name','Group','Home')
self.labels = []
self.entrys = []
for lst in frame:
self.labels.append(lst[0])
self.entrys.append(lst[1])
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.focus = -1
x = uiconfig.group_entry_pos_x
self.nrow = nrow = len(self.labels)
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.group_entry_pos_y1
elif nrow == 2: pos_y = uiconfig.group_entry_pos_y2
elif nrow == 3: pos_y = uiconfig.group_entry_pos_y3
# x = uiconfig.list_pos_x
self.pos_y = pos_y
i =0
while i < len(self.labels):
self.children.append(self.labels[i])
self.children.append(self.entrys[i])
i += 1
for i, y in enumerate(pos_y):
self.labels[i].set_position(uiconfig.input6p_x2, y+16-uiconfig.input_font[1]/2-2)
self.labels[i].set_text(self.choose[i])
self.labels[i].show()
self.entrys[i].setPosition(x, y)
self.entrys[i].show()
if nrow > 6: # draw scroll arrow
self.scroll_bg = utils.put_image('scroll_bg.png',(444,45),(4, 192))
self.scroll_bg.hide()
self.scroll_ball = utils.put_image('scroll_ball.png',(444,47),(4,int(192/len(self.labels))))
self.scroll_bg.hide()
self.children.append(self.scroll_bg)
self.children.append(self.scroll_ball)
self.set_focus(0)
def set_focus(self, focus):
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
hi_index = focus - self.top_index
if hi_index < 0 or len(self.pos_y) <= hi_index or focus == 9:
if focus in [9,11]:
hi_index = focus
self.top_index = 9
elif focus == 8:
hi_index = focus
self.top_index = 3
elif hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.list_pos_y6) + 1
print self.top_index,hi_index,focus
i =0
while i < len(self.labels):
self.labels[i].hide()
self.entrys[i].hide()
i += 1
x = uiconfig.group_entry_pos_x
for i, y in enumerate(self.pos_y):
if (i + self.top_index) < len(self.choose):
self.labels[i+self.top_index].set_position(uiconfig.input6p_x2, y+16-uiconfig.input_font[1]/2-2)
self.labels[i+self.top_index].set_text(self.choose[i+self.top_index])
self.labels[i+self.top_index].show()
if (i + self.top_index) == len(self.choose) - 1:
self.entrys[i+self.top_index].setPosition(x+70, y)
self.entrys[i+self.top_index].show()
else:
self.entrys[i+self.top_index].setPosition(x, y)
self.entrys[i+self.top_index].show()
self.focus = focus
if len(self.labels) > 6:
self.scroll_ball.move(444,int(192/len(self.labels)) + self.focus * int(192/len(self.labels)) + 47 - int(192/len(self.labels)) )
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def show(self):
#self.set_focus(self.focus)
Widget.show(self)
i =6
while i < len(self.labels):
self.labels[i].hide()
self.entrys[i].hide()
i += 1
def hide(self):
#self.remove_item_scroll_timer()
Widget.hide(self)
def free(self):
#self.remove_item_scroll_timer()
Widget.free(self)
# KA: [30080429] other way ==
class ChangePassword(Widget):
def __init__(self, frame, unselbarpos=[]):
import status
Widget.__init__(self)
self.unselbarpos = unselbarpos
self.choose = (_('New password'),_('Re input'))
self.icons = []
self.labels = []
self.entrys = []
for lst in frame:
self.icons.append(lst[0])
self.labels.append(lst[1])
self.entrys.append(lst[2])
self.top_index = 0
self.focus = -1
self.nrow = len(self.labels)
self.pos_y = uiconfig.pw_entry_pos_y2
i =0
while i < len(self.labels):
self.children.append(self.icons[i])
self.children.append(self.labels[i])
self.children.append(self.entrys[i])
i += 1
for i, y in enumerate(self.pos_y):
self.icons[i].setPosition(uiconfig.pw_entry_pos_x1, self.pos_y[i]+4)
self.icons[i].show()
self.labels[i].set_position(uiconfig.pw_entry_pos_x2, self.pos_y[i]+16-uiconfig.input_font[1]/2-2)
self.labels[i].set_text(self.choose[i])
self.labels[i].show()
self.entrys[i].setPosition(uiconfig.pw_entry_pos_x3, self.pos_y[i])
self.entrys[i].set_text('')
self.entrys[i].show()
self.set_focus(0)
def set_focus(self, focus):
import status
if self.nrow == 0:
return
if focus < 0: focus = self.nrow + focus
hi_index = focus - self.top_index
if hi_index < 0 or len(self.pos_y) <= hi_index:
if hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.pw_entry_pos_y2) + 1
i =0
while i < len(self.labels):
self.icons[i].hide()
self.labels[i].hide()
self.entrys[i].hide()
i += 1
for i, y in enumerate(self.pos_y):
self.icons[i+self.top_index].setPosition(uiconfig.pw_entry_pos_x1, y+4)
self.icons[i+self.top_index].show()
self.labels[i+self.top_index].set_position(uiconfig.pw_entry_pos_x2, y+16-uiconfig.input_font[1]/2-2)
self.labels[i+self.top_index].set_text(self.choose[i+self.top_index])
self.labels[i+self.top_index].show()
self.entrys[i+self.top_index].setPosition(uiconfig.pw_entry_pos_x3, y)
self.entrys[i+self.top_index].set_text(self.entrys[i+self.top_index].get_text())
self.entrys[i+self.top_index].show()
self.focus = focus
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def show(self):
Widget.show(self)
i = 6
while i < len(self.labels):
self.icons[i].hide()
self.labels[i].hide()
self.entrys[i].hide()
i += 1
def hide(self):
Widget.hide(self)
def free(self):
Widget.free(self)
class NetworkRegister(Widget):
def __init__(self, frame, unselbarpos=[]):
self.unselbarpos = unselbarpos
import status
Widget.__init__(self)
self.icon_columns = []
self.choose = ('Choice','IP Address','Subnetmask','Gateway','DNS1','DNS2')
self.labels = []
self.entrys = []
for lst in frame:
self.labels.append(lst[0])
self.entrys.append(lst[1])
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.focus = -1
self.nrow = nrow = len(self.labels)
x = 210
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.setting_entry_pos_y1
elif nrow == 2: pos_y = uiconfig.setting_entry_pos_y2
elif nrow == 3: pos_y = uiconfig.setting_entry_pos_y3
elif nrow == 4: pos_y = uiconfig.setting_entry_pos_y4
elif nrow == 5: pos_y = uiconfig.setting_entry_pos_y5
else: pos_y = uiconfig.setting_entry_pos_y6
# x = uiconfig.list_pos_x
self.pos_y = pos_y
i =0
while i < len(self.labels):
self.children.append(self.labels[i])
self.children.append(self.entrys[i])
i += 1
for i, y in enumerate(pos_y):
self.labels[i].set_position(x-132, y+16-uiconfig.input_font[1]/2-2)
self.labels[i].set_text(self.choose[i])
self.labels[i].show()
self.entrys[i].setPosition(x, y)
self.entrys[i].show()
self.set_focus(0)
def set_focus(self, focus):
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
hi_index = focus - self.top_index
if hi_index < 0 or len(self.pos_y) <= hi_index:
if hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.setting_entry_pos_y6) + 1
i =0
while i < len(self.labels):
self.labels[i].hide()
self.entrys[i].hide()
i += 1
x = uiconfig.pb_entry_pos_x
for i, y in enumerate(self.pos_y):
self.labels[i+self.top_index].set_position(x-100, y+3)
self.labels[i+self.top_index].set_text(self.choose[i+self.top_index])
self.labels[i+self.top_index].show()
self.entrys[i+self.top_index].setPosition(x+10, y+5)
self.entrys[i+self.top_index].show()
self.focus = focus
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def show(self):
#self.set_focus(self.focus)
Widget.show(self)
i =6
while i < len(self.labels):
self.labels[i].hide()
self.entrys[i].hide()
i += 1
def hide(self):
#self.remove_item_scroll_timer()
Widget.hide(self)
def free(self):
#self.remove_item_scroll_timer()
Widget.free(self)
class FlagIconColumn(Widget):
def __init__(self, x, deltay, icons, resize = [0,0]):
self.resize = resize
Widget.__init__(self)
self.x = x
self.top_idx = 0
self.icons = icons
self.first_show = True
self.images = [None, None, None, None, None, None]
self.disp_rows = len(icons)
if self.disp_rows > 6:
self.disp_rows = 6
if self.disp_rows == 0: self.pos_y = []
elif self.disp_rows == 1: self.pos_y = [y+deltay for y in uiconfig.list2_pos_y1] #uiconfig.flag_icon_column_y1_list
elif self.disp_rows == 2: self.pos_y = [y+deltay for y in uiconfig.list2_pos_y2] #uiconfig.flag_icon_column_y2_list
elif self.disp_rows == 3: self.pos_y = [y+deltay for y in uiconfig.list2_pos_y3] #uiconfig.flag_icon_column_y3_list
elif self.disp_rows == 4: self.pos_y = [y+deltay for y in uiconfig.list2_pos_y4] #uiconfig.flag_icon_column_y4_list
elif self.disp_rows == 5: self.pos_y = [y+deltay for y in uiconfig.list2_pos_y5] #uiconfig.flag_icon_column_y5_list
else: self.pos_y = [y+deltay for y in uiconfig.list2_pos_y6] #uiconfig.flag_icon_column_y6_list
def show(self):
if self.first_show:
self.set_top_index(self.top_idx)
self.first_show = False
for i in range(self.disp_rows):
idx = self.top_idx + i
if idx >= len(self.icons):
idx -= len(self.icons)
if self.icons[idx]:
if self.images[i]: self.images[i].show()
else:
if self.images[i]: self.images[i].hide()
def hide(self):
for i in self.images:
if i: i.hide()
Widget.hide(self)
def free(self):
for i in self.images:
if i: i.free()
Widget.free(self)
def set_top_index(self, top_idx):
self.top_idx = top_idx
for i in range(self.disp_rows):
idx = self.top_idx + i
if idx >= len(self.icons):
idx -= len(self.icons)
if self.icons[idx]:
if self.images[i]: self.images[i].free()
x = self.x
y = self.pos_y[i]
if self.resize[0] == 0 and self.resize[1] == 0:
self.images[i] = utils.put_image(self.icons[idx], (x,y))
else:
self.images[i] = utils.put_image_sized(self.icons[idx], (x,y), tuple(self.resize))
else:
if self.images[i]: self.images[i].hide()
def length(self):
return len(self.icons)
def set_icon(self, i, icon):
self.icons[i] = icon
self.set_top_index(self.top_idx)
# KA: [20080406] phonebook multiselect icon
class PhonebookIconColumn(Widget):
def __init__(self, icons, resize = [0,0]):
self.resize = resize
Widget.__init__(self)
self.x = uiconfig.pb_sel_pos_x
self.top_idx = 0
self.icons = icons
self.first_show = True
self.images = [None, None, None, None,None]
self.disp_rows = len(icons)
if self.disp_rows > 5:
self.disp_rows = 5
if self.disp_rows == 0: self.pos_y = []
elif self.disp_rows == 1: self.pos_y = uiconfig.pb_sel_pos_y1
elif self.disp_rows == 2: self.pos_y = uiconfig.pb_sel_pos_y2
elif self.disp_rows == 3: self.pos_y = uiconfig.pb_sel_pos_y3
elif self.disp_rows == 4: self.pos_y = uiconfig.pb_sel_pos_y4
else: self.pos_y = uiconfig.pb_sel_pos_y5
def show(self):
if self.first_show:
self.set_top_index(self.top_idx)
self.first_show = False
for i in range(self.disp_rows):
idx = self.top_idx + i
if idx >= len(self.icons):
idx -= len(self.icons)
if self.icons[idx]:
if self.images[i]: self.images[i].show()
else:
if self.images[i]: self.images[i].hide()
def hide(self):
for i in self.images:
if i: i.hide()
Widget.hide(self)
def free(self):
for i in self.images:
if i: i.free()
Widget.free(self)
def set_top_index(self, top_idx):
self.top_idx = top_idx
for i in range(self.disp_rows):
idx = self.top_idx + i
if idx >= len(self.icons):
idx -= len(self.icons)
if self.icons[idx]:
if self.images[i]: self.images[i].free()
x = self.x
y = self.pos_y[i]
if self.resize[0] == 0 and self.resize[1] == 0:
self.images[i] = utils.put_image(self.icons[idx], (x,y))
else:
self.images[i] = utils.put_image_sized(self.icons[idx], (x,y), tuple(self.resize))
else:
if self.images[i]: self.images[i].hide()
def length(self):
return len(self.icons)
def set_icon(self, i, icon):
self.icons[i] = icon
self.set_top_index(self.top_idx)
class WorldTimeListLabel(Widget):
def __init__(self, text, font, pos, color, align=uiconfig.ALIGN_LEFT):
Widget.__init__(self)
self.align = align
self.pos = pos
self.color = color
self.font = font
self._text = utils.get_real_lang_str(text)
#self.text_width = 0
self.set_text(text)
# def get_text_width(self):
#etext = runtime.evas.text(text=self._text, font=self.font, color=self.color)
#self.text_width = etext.geometry[2]
#etext.free()
#return self.text_width
def set_text(self, text, with_punc = True):
self.free()
self.children = []
x, y = self.pos
lang_text = utils.get_real_lang_str(text)
#if with_punc:
# text = utils.cut_text_with_punc(lang_text, uiconfig.item_width_scroll, uiconfig.list_font)[0]
#else:
# text = utils.cut_text(lang_text, uiconfig.item_width_scroll, uiconfig.list_font)[0]
etext = runtime.evas.text(text=text, font=self.font,color=self.color)
geometry = etext.geometry
etext.pos = x, y
self.children.append(etext)
y += etext.geometry[3]
if etext and not self.hidden:
self.show()
def set_color(self, color):
self.color = color
for w in self.children:
w.color = color
def change_language(self):
text = self._text
self.set_text('')
self.set_text(text)
if self.hidden:
self.hide()
#thang[20080327-1]=========================
class IconColumn(Widget):
def __init__(self, x, icons, resize = [0,0]):
self.resize = resize
Widget.__init__(self)
self.x = x
self.top_idx = 0
self.icons = icons
self.first_show = True
self.images = [None, None, None, None,None,None]
self.disp_rows = len(icons)
if self.disp_rows > 6:
self.disp_rows = 6
if self.disp_rows == 0: self.pos_y = []
elif self.disp_rows == 1: self.pos_y = uiconfig.icon_column_y1_list
elif self.disp_rows == 2: self.pos_y = uiconfig.icon_column_y2_list
elif self.disp_rows == 3: self.pos_y = uiconfig.icon_column_y3_list
elif self.disp_rows == 4: self.pos_y = uiconfig.icon_column_y4_list
elif self.disp_rows == 5: self.pos_y = uiconfig.icon_column_y5_list
else: self.pos_y = uiconfig.icon_column_y6_list
def show(self):
if self.first_show:
self.set_top_index(self.top_idx)
self.first_show = False
for i in range(self.disp_rows):
idx = self.top_idx + i
if idx >= len(self.icons):
idx -= len(self.icons)
if self.icons[idx]:
if self.images[i]: self.images[i].show()
else:
if self.images[i]: self.images[i].hide()
def hide(self):
for i in self.images:
if i: i.hide()
Widget.hide(self)
def free(self):
for i in self.images:
if i: i.free()
Widget.free(self)
def set_top_index(self, top_idx):
self.top_idx = top_idx
#print 'ka....####### self.icons=', self.icons
#print 'ka....####### self.top_idx=', self.top_idx
#print 'ka....####### self.resize=', self.resize
for i in range(self.disp_rows):
idx = self.top_idx + i
if idx >= len(self.icons):
idx -= len(self.icons)
if self.icons[idx]:
if self.images[i]: self.images[i].free()
x = self.x
y = self.pos_y[i]
if self.resize[0] == 0 and self.resize[1] == 0:
self.images[i] = utils.put_image(self.icons[idx], (x,y))
else:
self.images[i] = utils.put_image_sized(self.icons[idx], (x,y), tuple(self.resize))
else:
if self.images[i]: self.images[i].hide()
def length(self):
return len(self.icons)
def set_icon(self, i, icon):
self.icons[i] = icon
self.set_top_index(self.top_idx)
#thang [20080315] -2 setup line,icont, scroll line for 2 depth
class ChkList(Widget):
def __init__(self, labels, unselbarpos=[]):
self.unselbarpos = unselbarpos
import status
Widget.__init__(self)
self.icon_columns = []
self.up_arrow = None
self.down_arrow = None
self.labels = []
for lst in labels:
self.labels.append(utils.get_real_lang_str(lst))
self.org_label = None
self.scroll_text = None
self.temp_text = None
self.item_scroll_timer = None
self.top_index = 0
self.items = []
self.focus = -1
x = uiconfig.image_list_pos_x
self.nrow = nrow = len(self.labels)
if nrow == 0: pos_y = []
elif nrow == 1: pos_y = uiconfig.list_pos_y1
elif nrow == 2: pos_y = uiconfig.list_pos_y2
elif nrow == 3: pos_y = uiconfig.list_pos_y3
elif nrow == 4: pos_y = uiconfig.list_pos_y4
elif nrow == 5: pos_y = uiconfig.list_pos_y5
else: pos_y = uiconfig.list_pos_y6
x = uiconfig.image_list_pos_x
self.pos_y = pos_y
for i, y in enumerate(pos_y):
image = utils.put_image(uiconfig.current_theme.unselected_bar, (x,y+2))
image.hide()
pos = x + uiconfig.list_pos_text_delta_x + 10, y + uiconfig.list_pos_text_delta_y
if status.phonebook_emergency and i==0 and status.phonebook_isempty:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
elif status.phonebook_emergency and i==0:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
else:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
self.items.append((image, text))
self.children.append(image)
self.children.append(text)
for y in uiconfig.underbar_pos_y:
underbar = utils.put_image(uiconfig.under_bar, (uiconfig.underbar_pos_x, y))
underbar.hide()
self.children.append(underbar)
if nrow > 6: # draw scroll arrow
self.up_arrow = utils.put_image(uiconfig.up_arrow, (452,34))
self.up_arrow.hide()
self.down_arrow = utils.put_image(uiconfig.down_arrow, (451,35),(4,int(198/len(self.labels)) ))
self.down_arrow.hide()
self.children.append(self.up_arrow)
self.children.append(self.down_arrow)
self.set_focus(0)
#---------------------------------
# List Item 이 선택되었음
#---------------------------------
def set_focus(self, focus):
import status
if self.nrow == 0:
return
if self.focus == -1:
selected_olditem = False
else:
selected_olditem = True
if focus < 0:
focus = self.nrow + focus
self.remove_item_scroll_timer()
if self.focus >= 0:
image, text = self.items[self.focus - self.top_index]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
# OLD/NEW item text
hi_index = focus - self.top_index
# 스크롤이 화면범위를 벗어나 update가 필요한 경우
if hi_index < 0 or len(uiconfig.list_pos_y6) <= hi_index:
if hi_index < 0:
self.top_index += hi_index
else:
self.top_index += hi_index - len(uiconfig.list_pos_y6) + 1
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(uiconfig.list_pos_y6)):
image, text = self.items[i]
text.set_text( self.labels[self.top_index + i] )
if status.phonebook_emergency and i==0 and status.phonebook_isempty:
text = ListLabel(text=self.labels[i], pos=pos, color=uiconfig.list_text_emergency_color, font=uiconfig.list_font, align=uiconfig.ALIGN_LEFT)
elif status.phonebook_emergency and self.top_index == 0 and i == 0:# and len(self.labels) > 1:
text.set_color(uiconfig.list_text_emergency_color)
else:
text.set_color(uiconfig.list_text_color)
else:
# prev item을 다시 그림
# 글자가 긴 경우 잘라서(blabla...)그림
if selected_olditem:
old_image, old_text, = self.items[self.focus - self.top_index]
old_image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
old_text.set_text(self.labels[self.focus])
self.focus = focus
if len(self.labels) > 6:
#self.down_arrow.move(uiconfig.list_down_arrow_pos[0],int(158/len(self.labels)) + self.focus * int(158/len(self.labels)) )
#self.down_arrow.move(452,int(198/len(self.labels)) + self.focus * int(198/len(self.labels))+ 36 - int(198/len(self.labels)) )
self.down_arrow.move(452,34 + int(self.focus * float(198.0/len(self.labels))) )
image, text = self.items[focus - self.top_index]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + uiconfig.image_list_menu_selection
image.size = 280,30
def scroll_item_timer_cb():
try:
# KA: [20070921] this conversion is required for Korean text
#if ord(self.temp_text[0]) > 127:
latin_char = True
if type(self.temp_text) == type('abc'):
self.temp_text = unicode(self.temp_text, 'utf-8')[1:]
else:
self.temp_text = self.temp_text[1:]
self.temp_text = self.temp_text.encode('utf-8')
except:
self.temp_text = ''
if len(self.temp_text) == 0:
self.temp_text = self.org_label
abbr_text = set_scroll_text(self.temp_text, uiconfig.item_width_scroll)
self.scroll_text.set_text(abbr_text, False)
runtime.evas.render()
return True
'''
def scroll_item_timer_cb():
try:
if ord(self.temp_text[0]) > 127:
latin_char = True
self.temp_text = self.temp_text[2:]
else:
latin_char = False
self.temp_text = self.temp_text[1:]
except:
self.temp_text = ''
if len(self.temp_text) == 0:
self.temp_text = self.org_label
abbr_text = set_scroll_text(self.temp_text, uiconfig.item_width_scroll)
self.scroll_text.set_text(abbr_text, False)
runtime.evas.render()
return True
'''
def set_scroll_text(item_text, abbr_width):
if abbr_width > 0:
abbr_text = utils.cut_text(item_text, abbr_width, uiconfig.list_font)[0]
return abbr_text
else:
return item_text
def is_scroll_item(item_text):
etext = runtime.evas.text(text=item_text, font=uiconfig.list_font, color=uiconfig.list_text_color)
text_width = etext.geometry[2]
etext.free()
if text_width > uiconfig.item_width_scroll:
return True
else:
return False
#스크롤 할지를 결정
if is_scroll_item(self.labels[focus]) == True:
self.org_label = self.temp_text = self.labels[self.focus]
item_text = set_scroll_text(self.temp_text, uiconfig.item_width_scroll)
text.set_text(item_text)
self.scroll_text = text
self.item_scroll_timer = utils.Timer(400, scroll_item_timer_cb)
else:
text.set_text(self.labels[self.focus])
def remove_item_scroll_timer(self):
if self.item_scroll_timer:
del(self.item_scroll_timer)
self.item_scroll_timer = None
self.scroll_text = None
self.temp_text = None
def show(self):
self.set_focus(self.focus)
Widget.show(self)
def hide(self):
self.remove_item_scroll_timer()
Widget.hide(self)
def free(self):
self.remove_item_scroll_timer()
Widget.free(self)
def set_init_focus(self, focus, top_index):
if self.nrow == 0:
return
self.focus = focus
self.top_index = top_index
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
for i in range(len(self.items)):
image, text = self.items[i]
image.file = uiconfig.image_dir + uiconfig.current_theme.unselected_bar
text.set_text( self.labels[self.top_index + i] )
image, text = self.items[focus - self.top_index]
if self.focus in self.unselbarpos:
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_disable
else:
image.file = uiconfig.image_dir + uiconfig.image_list_menu_selection
image.size = 280,30
def focus_up(self):
if self.focus > 0:
self.set_focus(self.focus - 1)
else:
self.set_focus(self.nrow - 1)
def focus_down(self):
if self.focus < len(self.labels) - 1:
self.set_focus(self.focus + 1)
else:
self.set_focus(0)
def set_text(self, n, text):
roxia_trace('**** List.set_text(), n=', n, 'text=', text)
if type(self.labels) == type((0,)):
self.labels = list(self.labels)
self.labels[n] = text
vindex = n - self.top_index
if 0 <= vindex < len(self.pos_y):
r, t = self.items[vindex]
t.set_text(text)
def change_language(self):
for i in range(len(self.pos_y)):
r, t = self.items[i]
t.set_text('')
t.set_text( self.labels[i + self.top_index] )
def change_theme(self):
image, text = self.items[self.focus - self.top_index]
image.file = uiconfig.image_dir + uiconfig.current_theme.menu_selection
image.size = 280,30
def attach_icon_column(self, ic):
self.icon_columns.append(ic)
def remove_all_icon_columns(self):
self.icon_columns = []
def update_icon_index(self):
for ic in self.icon_columns:
ic.set_top_index(self.top_index)
class CheckList(ChkList):
def __init__(self, labels, use_radio_style=False, use_slide_icon=True):
ChkList.__init__(self, labels)
self.use_radio_style = use_radio_style
self.use_slide_icon = use_slide_icon
self.checked = [False] * len(labels)
self.mark_ic = IconColumn(179, [None] * len(labels))
self.attach_icon_column(self.mark_ic)
self.children.append(self.mark_ic)
if self.use_slide_icon:
self.slide_ic = IconColumn(425, [None] * len(labels))
self.attach_icon_column(self.slide_ic)
self.children.append(self.slide_ic)
self.slide_ic.hide()
for i in range(len(labels)):
if labels[i].endswith('/') or labels[i].endswith('..'):
self.mark_ic.set_icon(i, uiconfig.icon_directory)
else:
if self.use_radio_style:
self.mark_ic.set_icon(i, uiconfig.check_icon_unselected)
else:
self.mark_ic.set_icon(i, uiconfig.check_unselect)
def set_check(self, focus, check):
if self.checked[focus] == check:
return
self.checked[focus] = check
if check:
if self.use_radio_style:
self.mark_ic.set_icon(focus, uiconfig.check_icon_selected)
else:
self.mark_ic.set_icon(focus, uiconfig.check_select)
# if self.use_slide_icon:
# self.slide_ic.set_icon(focus, uiconfig.image_list_icon)
else:
if self.use_radio_style:
self.mark_ic.set_icon(focus, uiconfig.check_icon_unselected)
else:
self.mark_ic.set_icon(focus, uiconfig.check_unselect)
# if self.use_slide_icon:
# self.slide_ic.set_icon(focus, None)
def set_slide_check(self, focus, check):
if check:
self.slide_ic.set_icon(focus, uiconfig.image_list_icon)
else:
self.slide_ic.set_icon(focus, None)
def set_choice(self,focus):
for i in range(len(self.labels)):
if i == focus:
if self.use_radio_style:
self.mark_ic.set_icon(focus,uiconfig.check_icon_selected)
else:
self.mark_ic.set_icon(focus, uiconfig.check_select)
else:
if self.use_radio_style:
self.mark_ic.set_icon(i ,uiconfig.check_icon_unselected)
else:
self.mark_ic.set_icon(focus, uiconfig.check_unselect)
def toggle(self, focus=None):
if focus == None:
focus = self.focus
self.set_check(focus, not self.checked[focus])
def change_choice(self, focus=None):
if focus == None:
focus = self.focus
self.set_choice(focus)
def change_choice_up(self): # this routine is just for self.use_radio_style
#print '>>>>>>>>>>> [UP] self.focus = %d, self.nrow = %d, len(self.labels) = %d' % (self.focus, self.nrow, len(self.labels))
if self.focus < len(self.labels) - 1:
self.mark_ic.set_icon(self.focus, uiconfig.check_icon_selected)
self.mark_ic.set_icon(self.focus + 1, uiconfig.check_icon_unselected)
else:
self.mark_ic.set_icon(self.nrow - 1, uiconfig.check_icon_selected)
def change_choice_down(self): # this routine is just for self.use_radio_style
#print '>>>>>>>>>>> [DOWN] self.focus = %d, self.nrow = %d, len(self.labels) = %d' % (self.focus, self.nrow, len(self.labels))
if self.focus > 0:
self.mark_ic.set_icon(self.focus, uiconfig.check_icon_selected)
self.mark_ic.set_icon(self.focus - 1, uiconfig.check_icon_unselected)
else:
self.mark_ic.set_icon(0, uiconfig.check_icon_selected)
class Gauge(Widget):
def __init__(self):
Widget.__init__(self)
self.images = []
self.value = -1
self.min = 1
self.max = uiconfig.gauge_level_count # 5
self.posx, self.posy = uiconfig.small_window_bar_pos
pos = uiconfig.gauge_up_pos
self.up_arrow = utils.put_image(uiconfig.up_arrow, (pos[0] + self.posx, pos[1] + self.posy))
pos = uiconfig.gauge_down_pos
self.down_arrow = utils.put_image(uiconfig.down_arrow, (pos[0] + self.posx, pos[1] + self.posy))
self.children.append(self.up_arrow)
self.children.append(self.down_arrow)
self.set_value(0)
def value_up(self):
roxia_trace(self.value, 'vol +')
if self.value == self.min:
self.down_arrow.show()
if self.value < uiconfig.gauge_level_count:
self.set_value(self.value + 1)
if self.value >= self.max:
self.up_arrow.hide()
def update_arrow(self):
if self.value == self.max:
self.up_arrow.hide()
if self.value == self.min:
self.down_arrow.hide()
def value_down(self):
roxia_trace(self.value, 'vol -')
if self.value == self.max:
self.up_arrow.show()
if self.value > self.min:
self.set_value(self.value - 1)
if self.value <= self.min:
self.down_arrow.hide()
def set_value(self, value):
roxia_trace('Gauge.set_value(), value=', value)
if value == self.value:
roxia_trace('value equal, return')
return
self.value = value
self.free()
self.children = []
for i in range(self.value):
image = utils.put_image(uiconfig.gauge_images[i], uiconfig.gauge_pos[i])
self.children.append(image)
if image and not self.hidden:
self.show()
def get_value(self):
return self.value
class ListLabel(Widget):
def __init__(self, text, font, pos, color, align=uiconfig.ALIGN_LEFT):
Widget.__init__(self)
self.align = align
self.pos = pos
self.color = color
self.font = font
self._text = utils.get_real_lang_str(text)
self.text_width = 0
self.set_text(text)
def get_text_width(self):
etext = runtime.evas.text(text=self._text, font=self.font, color=self.color)
self.text_width = etext.geometry[2]
etext.free()
return self.text_width
def set_text(self, text, with_punc = True):
self.free()
self.children = []
x, y = self.pos
lang_text = utils.get_real_lang_str(text)
if with_punc:
text = utils.cut_text_with_punc(lang_text, uiconfig.item_width_scroll, uiconfig.list_font)[0]
else:
text = utils.cut_text(lang_text, uiconfig.item_width_scroll, uiconfig.list_font)[0]
etext = runtime.evas.text(text=text, font=self.font,color=self.color)
geometry = etext.geometry
etext.pos = x, y
self.children.append(etext)
y += etext.geometry[3]
if etext and not self.hidden:
self.show()
def set_color(self, color):
self.color = color
for w in self.children:
w.color = color
def change_language(self):
text = self._text
self.set_text('')
self.set_text(text)
if self.hidden:
self.hide()
class Label(Widget):
# center aligned multi-line text
def __init__(self, text, font, pos, color, align=uiconfig.ALIGN_CENTER):
Widget.__init__(self)
self.align = align
self.pos = pos
self.color = color
self.font = font
self._text = ''
self.text_width = 0
self.set_text(text)
def set_text(self, text):
if self._text == text:
return
self._text = text
self.free()
self.children = []
text_lines = text
tmp_l = runtime.evas.text(text=text_lines)
text_lines = tmp_l.text_get()
lines = text_lines.split('\n')
tmp_l.free()
x, y = self.pos
for line in lines:
text = runtime.evas.text(text=line, font=self.font,color=self.color)
geometry = text.geometry
self.text_width = geometry[2]
if self.align == uiconfig.ALIGN_CENTER:
text.pos = (x - geometry[2]/2), y
elif self.align == uiconfig.ALIGN_RIGHT:
text.pos = (x - geometry[2]), y
elif self.align == uiconfig.ALIGN_LEFT:
text.pos = x, y
self.children.append(text)
y += text.geometry[3]
if text and not self.hidden:
self.show()
def set_text_top(self, text):
self._text = text
self.free()
self.children = []
text_lines = text
tmp_l = runtime.evas.text(text=text_lines)
text_lines = tmp_l.text_get()
lines = text_lines.split('\n')
tmp_l.free()
x, y = self.pos
for line in lines:
text = runtime.evas.text(text=line, font=self.font,color=self.color)
geometry = text.geometry
self.text_width = geometry[2]
if self.align == uiconfig.ALIGN_CENTER:
text.pos = (x - geometry[2]/2), y
elif self.align == uiconfig.ALIGN_RIGHT:
text.pos = (x - geometry[2]), y
elif self.align == uiconfig.ALIGN_LEFT:
text.pos = x, y
text.layer = 20
self.children.append(text)
y += text.geometry[3]
if text and not self.hidden:
self.show()
def set_color(self, color):
self.color = color
for w in self.children:
w.color = color
def change_language(self):
text = self._text
self.set_text('')
self.set_text(text)
if self.hidden:
self.hide()
class OutlineLabel(Label):
def __init__(self, text, font, pos, color, outline_color=None, align=uiconfig.ALIGN_CENTER, abbr_width=-1):
if outline_color == None:
outline_color = (0, 0, 0, 128)
self.outline_color = outline_color
self.align = align
self.abbr_width = abbr_width
Label.__init__(self, text, font, pos, color, align)
def set_text(self, text):
if self._text == text:
return
self._text = text
self.free()
self.children = []
text_lines = text
tmp_l = runtime.evas.text(text=text_lines)
text_lines = tmp_l.text_get()
lines = text_lines.split('\n')
tmp_l.free()
x, y = self.pos
for line in lines:
font = self.font
for x_off in (-1, 1, 0):
for y_off in (-1, 1, 0):
text = runtime.evas.text(text=line, font=font)
if x_off == 0 and y_off == 0:
text.color = self.color
else:
text.color = self.outline_color
if self.align == uiconfig.ALIGN_CENTER:
text.pos = (x - text.geometry[2]/2)+x_off, y+y_off
elif self.align == uiconfig.ALIGN_RIGHT:
text.pos = (x - text.geometry[2])+x_off, y+y_off
elif self.align == uiconfig.ALIGN_LEFT:
text.pos = x+x_off, y+y_off
self.children.append(text)
text = runtime.evas.text(text=line, font=font,color=self.color)
geometry = text.geometry
if self.align == uiconfig.ALIGN_CENTER:
text.pos = (x - geometry[2]/2), y
elif self.align == uiconfig.ALIGN_RIGHT:
text.pos = (x - geometry[2]), y
elif self.align == uiconfig.ALIGN_LEFT:
text.pos = x, y
self.children.append(text)
y += geometry[3]
if self.children and not self.hidden:
self.show()
text = property(None, set_text, None)
class OutlineLabelEx(OutlineLabel):
def __init__(self, text, font, pos, color, outline_color=None, align=ALIGN_CENTER, abbr_width=-1, valign = VALIGN_TOP):
if outline_color == None:
outline_color = (0, 0, 0, 128)
self.outline_color = outline_color
self.align = align
self.abbr_width = abbr_width
self.valign = valign
Label.__init__(self, text, font, pos, color, align)
def set_text(self, text, color=None):
if self._text == text:
return
self._text = text
self.free()
self.children = []
if color:
self.color = color
text_lines = text
tmp_l = runtime.evas.text(text=text_lines)
text_lines = tmp_l.text_get()
lines = text_lines.split('\n')
tmp_l.free()
x, y = self.pos
nlines = len(lines)
#print '### TEXT.POS A=', self.pos, len(lines)
for line in lines:
font = self.font
for x_off in (-1, 1, 0):
for y_off in (-1, 1, 0):
text = runtime.evas.text(text=line, font=font)
#print '### TEXT.GEOMETRY', text.geometry
if x_off == 0 and y_off == 0:
text.color = self.color
else:
text.color = self.outline_color
xcoord = ycoord = 0
if self.align == ALIGN_CENTER:
xcoord = (x - text.geometry[2]/2)+x_off
elif self.align == ALIGN_RIGHT:
xcoord = (x - text.geometry[2])+x_off
elif self.align == ALIGN_LEFT:
xcoord = x+x_off
if self.valign == VALIGN_CENTER:
ycoord = (y - text.geometry[3]*nlines/2)+y_off
elif self.valign == VALIGN_BOTTOM:
ycoord = (y - text.geometry[3]*nlines)+y_off
elif self.valign == VALIGN_TOP:
ycoord = y+y_off
text.pos = xcoord, ycoord
self.children.append(text)
#print '### TEXT.POS', text.pos
text = runtime.evas.text(text=line, font=font,color=self.color)
geometry = text.geometry
xcoord = ycoord = 0
if self.align == ALIGN_CENTER:
xcoord = (x - text.geometry[2]/2)+x_off
elif self.align == ALIGN_RIGHT:
xcoord = (x - text.geometry[2])+x_off
elif self.align == ALIGN_LEFT:
xcoord = x+x_off
if self.valign == VALIGN_CENTER:
ycoord = (y - text.geometry[3]*nlines/2)+y_off
elif self.valign == VALIGN_BOTTOM:
ycoord = (y - text.geometry[3]*nlines)+y_off
elif self.valign == VALIGN_TOP:
ycoord = y+y_off
text.pos = xcoord, ycoord
self.children.append(text)
y += geometry[3]
if self.children and not self.hidden:
self.show()
text = property(None, set_text, None)
class TitleLabel(Label):
label_width = 0
def __init__(self, text, font, pos, color, outline_color=None, abbr_width=-1):
if outline_color == None:
outline_color = (0, 0, 0, 128)
self.outline_color = outline_color
self.abbr_width = abbr_width
text = runtime.evas.pre_parse(text)
# t = runtime.evas.text(text=text, font=font)
# self.label_width = t.geometry[2]
# t.free()
Label.__init__(self, text, font, pos, color, uiconfig.ALIGN_LEFT)
def init_title(self, text):
#real_title = utils.get_real_lang_str(text)
if text==None:
text = ''
real_title = runtime.evas.pre_parse(text)
print 'read_title=', real_title, ', text=', text
title = runtime.evas.text(text=real_title, font=self.font,color=self.color)
self.label_width = title.geometry[2]
if title.horiz_advance_get() > self.label_width:
debugLogC('Width is not enough, cliped.!!!')
title.free()
self.set_title(real_title)
def set_title(self, text):
self.free()
self.children = []
line = text
x, y = self.pos
font = self.font
if self.abbr_width > 0:
line, font = utils.cut_text(line, self.abbr_width, font)
text = runtime.evas.text(text=line, font=font, color=self.color)
geometry = text.geometry
text.pos = x, y
self.children.append(text)
y += geometry[3]
if self.children and not self.hidden:
self.show()
# property????
text = property(None, set_title, None)
class Progress(Widget):
def __init__(self, pos, size, out_icon=None, in_icon=None):
Widget.__init__(self)
self.value = -1
self.max = 0
self.size = size
if out_icon != None:
self.out_image = utils.put_image(out_icon, pos)
self.children.append(self.out_image)
self.in_image = utils.put_image(in_icon, (pos[0]+2, pos[1]+2))
self.children.append(self.in_image)
def set_max_value(self, max):
self.max = max
self.in_image.resize(0, self.size[1])
def set_value(self, value):
self.value = int(value)
if self.value <= 0:
self.in_image.resize(0, self.size[1])
elif self.value >= self.max:
self.in_image.resize(self.size[0], self.size[1])
else:
# max 가 progress_size 보다 클 경우 float 로 계산하지 않으면 안됨
progress_size = float(self.size[0])
self.in_image.resize(int(self.value * (progress_size/self.max)), self.size[1])
runtime.evas.render_now()
class ProgressType2(Widget):
def __init__(self, pos, size, out_icon, in_icon):
Widget.__init__(self)
self.value = -1
self.max = 0
self.size = size
self.in_size = size[0]-3, size[1]-3
self.out_image = utils.put_image(out_icon, pos)
self.in_image = utils.put_image(in_icon, (pos[0]+2, pos[1]+2))
self.children.append(self.out_image)
self.children.append(self.in_image)
def set_max_value(self, max):
self.max = max
self.in_image.resize(0, self.in_size[1])
def set_value(self, value):
self.value = value
if self.value <= 0:
self.in_image.resize(0, self.in_size[1])
elif self.value >= self.max:
self.in_image.resize(self.in_size[0], self.in_size[1])
else:
# max 가 progress_size 보다 클 경우 float 로 계산하지 않으면 안됨
progress_size = float(self.in_size[0])
self.in_image.resize(int(self.value * (progress_size/self.max)), self.in_size[1])
class SNMPProgress(Widget):
def __init__(self, pos=None):
Widget.__init__(self)
if not pos:
pos = uiconfig.download_progress_image_pos
self.in_image = utils.put_image(uiconfig.download_progress_image[0], pos)
self.children.append(self.in_image)
def set_max_value(self, max):
self.max = max
self.in_image.resize(0, self.size[1])
def set_value(self, value):
# value- %
self.value = int(value)
if self.value == 0:
index = 0
elif self.value < 10:
index = 1
elif self.value < 20:
index = 2
elif self.value < 30:
index = 3
elif self.value < 40:
index = 4
elif self.value < 50:
index = 5
elif self.value < 60:
index = 6
elif self.value < 70:
index = 7
elif self.value < 80:
index = 8
elif self.value < 90:
index = 9
else: #self.value == 100:
index = 10
self.in_image.file = uiconfig.image_dir + uiconfig.download_progress_image[index]
runtime.evas.render_now()