Example #1
0
  def query(s,content=u'',title=None,type="query",colour=0x888888):
    if not title:title=s.TitleName
    s.super=2
    s.__imgOld.blit(s.__img)
    s.__img.clear(0)
    s.__img.blit(s.__imgOld,mask=s.__mask)
    s.title,s.content,s.type,s.colour=title,content,type,colour
    s.choice,s.field=0,None
    if s.type=="query":
      s.list=akntextutils.wrap_text_to_array(s.content,"dense",200)
      if len(s.list)<=1:
        list=s.list+(u'',)
      elif len(s.list)>5:
        list=s.list[:5]
      else:
        list=s.list
    else:
      list,s.list=[0]*4,[0]*4
    s.__drawQuery(list)

    s.__lock.wait()
    s.__img.blit(s.__imgOld)
    s.__redraw()
    s.super=0
    del title,s.title,s.list,content,s.content,s.type,type,s.field
    return s.choice
Example #2
0
 def start(s,
           resource,
           callback=lambda: None,
           func_delete=lambda: None,
           stop_callback=lambda: None,
           func_vector=lambda: None):
     s.y, s.z = 0, 0
     y = 0
     s.resource = resource
     s.callback = callback
     s.func_delete = func_delete
     s.stop_callback = stop_callback
     s.func_vector = func_vector
     if not s.resource:
         return None
     s.list = akntextutils.wrap_text_to_array(s.resource, 'annotation',
                                              s.size[0] - 25)
     s.lenlist = len(s.list)
     s.max_str_display = s.size[1] / 20
     s.imgsize = (s.size[0] - 10, min(s.max_str_display * 20,
                                      s.lenlist * 20))
     try:
         del s.img
     except AttributeError:
         pass
     s.img = Image.new(s.imgsize)
     s.capture.keys = [
         63495, 63496, 63497, 63498, 63557, 63554, 63555, 35, 42, 63586, 8
     ] + range(48, 58)
     s.capture.forwarding = 0
     aw.app.focus = s.focus
     s.capture.start()
     s.picture()
Example #3
0
    def note(s, content, title=None, waitTime=1):
        if not title: title = s.TitleName
        s.super = 1
        s.__imgOld.blit(s.__img)
        s.__img.clear(0)
        s.__img.blit(s.__imgOld, mask=s.__mask)

        list = akntextutils.wrap_text_to_array(content, "dense", 200)
        if len(list) <= 1: list += (u'', )
        elif len(list) > 6: list = list[:6]
        s.__img.polygon(s.rim((13, 130, 227, 160 + len(list) * 25)),
                        fill=0xa6f9f8)
        s.__img.polygon(s.rim((13, 130, 227, 160)), fill=0x2ad8ea)
        s.__img.line((14, 158, 225, 158), 0xffffff, width=2)
        s.__img.text(
            (120 - s.__img.measure_text(title,
                                        ("dense", 20))[0][2] / 2.0, 155),
            title, 0x0, ("dense", 20, FONT_BOLD | FONT_ANTIALIAS))
        for i in range(len(list)):
            s.__img.text((20, 180 + i * 25), list[i], 0x0,
                         ("dense", 18, FONT_ANTIALIAS))
        s.__redraw()
        e32.ao_sleep(waitTime)
        s.__img.blit(s.__imgOld)
        s.__redraw()
        s.super = 0
Example #4
0
 def start(s, resousce):
     try:
         y = aw.app.body.pos2xy(aw.app.body.get_pos())[1]
     except AttributeError:
         return None
     s.y, s.z = 0, 0
     s.resousce = resousce
     if not s.resousce:
         return None
     elif type(s.resousce) == type([]) or type(s.resousce) == type(()):
         s.mode = 'list'
         s.list = []
         for t in s.resousce:
             a = s.imgnone.measure_text(t[0],
                                        'dense',
                                        maxwidth=s.size[0] - 25)[2]
             if a < len(t[0]):
                 t[0] = '%s%s' % (t[0][:a - 1], u'...')
             s.list.append(t[0])
     elif type(s.resousce) == type(u''):
         s.list = akntextutils.wrap_text_to_array(s.resousce, 'dense',
                                                  s.size[0] - 25)
         s.mode = 'text'
     else:
         return None
     s.lenlist = len(s.list)
     center = s.size[1] / 2
     if aw.app.screen == 'normal':
         y += s.layout[1][1]
     if y > center + 8:
         s.max_str_display = (y - 17) / 16
         s.imgsize = (s.size[0] - 10,
                      min(s.max_str_display * 16, s.lenlist * 16))
         s.window_position = 5, 5
     else:
         s.max_str_display = (s.size[1] - y - 8) / 16
         s.imgsize = (s.size[0] - 10,
                      min(s.max_str_display * 16, s.lenlist * 16))
         s.window_position = 5, max(y + 2, s.size[1] - s.imgsize[1] - 5)
     try:
         del s.img
     except AttributeError:
         pass
     s.img = Image.new(s.imgsize)
     if s.mode == 'list':
         s.capture.keys = [63497, 63498, 63557, 63554, 63555]
     elif s.mode == 'text':
         s.capture.keys = [
             63495, 63496, 63497, 63498, 63557, 63554, 63555, 35, 42, 63586
         ] + range(48, 58)
     s.capture.forwarding = 0
     aw.app.focus = s.focus
     s.capture.start()
     s.picture()
Example #5
0
 def splitLines(s,content,width=200):
   return akntextutils.wrap_text_to_array(content,"dense",width)
from akntextutils import wrap_text_to_array
import appuifw, e32


def cn(x):
    return x.decode("utf-8")


appuifw.app.body = canvas = appuifw.Canvas()
lines = wrap_text_to_array(cn("这是使用了帖子中介绍的方法后的效果。文字自动分句显示了。"), "dense", 220)
#其中220表示每句话的长度,达到该值后即换行
x, y = 10, 10
#设定文字开始的坐标为(10,10)
for line in lines:
    y += 15
    #这里是换行时改变的距离,数值过小会导致文字重叠,你也可以改变x或者同时改变x,y以实现不同效果
    canvas.text((x, y), line, font="dense")
    canvas.text((10, 100), cn("这是未使用帖子中介绍的方法的效果。"), font="dense")
e32.Ao_lock().wait()
Example #7
0
def to_array(content, dense, width):
    return akntextutils.wrap_text_to_array(content, dense, width)